akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y,z;
};
Point operator-(const Point& a,const Point& b)
{
  Point ret={a.x-b.x,a.y-b.y,a.z-b.z};
  return ret;
}
double dot(Point a,Point b)
{
  return a.x*b.x+a.y*b.y+a.z*b.z;
}
Point cross(Point a,Point b)
{
  Point ret={a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
  return ret;
}
double norm(Point a)
{
  return a.x*a.x+a.y*a.y+a.z*a.z;
}

string board[55];
int H,W;
int n;
bool visited[55][55];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
typedef pair<int,int> P;

bool isrect(int x,int y)
{
  int left,right,top,bottom;
  left=right=x;
  top=bottom=y;
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  if(board[i][j]==board[y][x])
	    {
	      if(j<left) left=j;
	      if(j>right) right=j;
	      if(i<top) top=i;
	      if(i>bottom) bottom=i;
	    }
	}
    }
  for(int i=top;i<bottom+1;i++)
    {
      for(int j=left;j<right+1;j++)
	{
	  if(board[i][j]!=board[y][x] && !visited[i][j]) return false;
	}
    }
  return true;
}

void draw(int x,int y,char c)
{
  if(visited[y][x]) return;
  visited[y][x]=true;
  for(int i=0;i<4;i++)
    {
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(nx<0 || W<=nx || ny<0 || H<=ny) continue;
      if(board[ny][nx]!=c) continue;
      draw(nx,ny,c);
    }
}

bool isSafe()
{
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  if(board[i][j]!='.' && !visited[i][j]) return false;
	}
    }
  return true;
}


int main(int argc,char const* argv[])
{
  cin >> n;
  for(int k=0;k<n;k++)
    {
      cin >> H >> W;
      memset(visited,false,sizeof(visited));
      for(int j=0;j<H;j++)
	{
	  cin >> board[j];
	}
      while(1)
	{
	  bool end=true;
	  bool update=false;
	  for(int i=0;i<H;i++)
	    {
	      for(int j=0;j<W;j++)
		{
		  if(board[i][j]=='.') continue;
		  if(visited[i][j]) continue;
		  end=false;
		  if(isrect(j,i))
		    {
		      update=true;
		      draw(j,i,board[i][j]);
		    }
		}
	    }
	  if(end || !update) break;
	}
      if(isSafe())
	{
	  cout << "SAFE" << endl;
	}
      else
	{
	  cout << "SUSPICIOUS" << endl;
	}
    }
  return 0;
}



Measured memory_bytes: 3264
//Code By: pratibha_899 (Pratibha Shrivastav)
 
/********   All Required Header Files ********/
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
 
using namespace std;
 
//All the Loops and defines required
typedef long long int ll;
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
 
//All the declarations using typedef
 
typedef pair<ll, ll> PII;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll, ll> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int l;
typedef unsigned long int ul;
typedef unsigned long long int  ull;

const ll INFI = 1e18 + 7;
 
ll knapsack(ll n,ll w, ll weights[], ll values[],ll sum_values){
	ll dp[n+1][sum_values+1];
	for(ll i=0;i<n+1;i++){
		for(ll j=0;j<sum_values+1;j++)
			dp[i][j]=INFI;
	}
	for(ll i=0;i<n+1;i++)
		dp[i][0]=0;
	
	for(ll i=1;i<n+1;i++){
		for(ll j=sum_values;j>=0;j--){
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-values[i]]+weights[i]);
		}
	}
	int max_value;
	for(ll i=0;i<sum_values+1;i++){
		if(dp[n][i]<=w)
			max_value=i;
	}
	return max_value;
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,w;
	cin>>n>>w;
	ll weights[n+1];
	ll values[n+1];
	for(ll i=1;i<=n;i++)
		cin>>weights[i]>>values[i];
	ll sum_values=0;
	for(ll i=1;i<=n;i++)
		sum_values+=values[i];
	ll res = knapsack(n,w,weights,values,sum_values);
	cout<<res;
	return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll sum = abs(a-b)+abs(a-c)+abs(b-c);;
    cout<<sum-max(abs(a-b),max(abs(a-c),abs(b-c)));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#define ll long long
#define int ll
#define lowbit(a) a&(-a)
using namespace std;

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

const int N=200000;
const int M=100000;
int n,m,a[N+5];
ll t[N+5],c[N+5],tem;

inline void add(int x){for(;x<=N;x+=lowbit(x)) t[x]++;}

inline ll ask(int x){ll ret=0;for(;x;x-=lowbit(x)) ret+=t[x];return ret;}

inline int check(int x){
	ll cnt=0;
	memset(t,0,sizeof(t));
	for(int i=1;i<=n;i++) c[i]=c[i-1]+(a[i]<=x? 1:-1);
	add(1+M);
	for(int i=1;i<=n;i++){
		cnt+=ask(c[i]+M);
		add(c[i]+1+M);
	}
	return cnt>tem;
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	ll l=0,r=0;
	for(int i=1;i<=n;i++) r=max(r,(ll)a[i]);
	ll ans=r;
	tem=n*(n+1)/2;tem/=2;
	while(l<=r){
	ll mid=(l+r)>>1;
	if(check(mid)) ans=min(ans,mid),r=mid-1;
	else l=mid+1;
}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
char str[1100][1100];
ll dp[1100][1100];
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m;
  cin>>n>>m;
  ll i,j;
  for(i=0;i<n;i++)
  {
      for(j=0;j<m;j++)
      {
          cin>>str[i][j];
      }
  }
  dp[0][0]=1;
  for(i=0;i<n;i++)
  {
      for(j=0;j<m;j++)
      {
        if(str[i][j]=='#')
        continue;
        if(i-1>=0)
        dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
        if(j-1>=0)
        dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
      }
  }
  cout<<dp[n-1][m-1]<<'\n';
   
   
  return 0;
}

Measured memory_bytes: 10752
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let a: i32 = vec[0].parse().unwrap();
    if a > 999 {println!("ABD", );} else {println!{"ABC"}};
}


Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))
dp = [0] * 100001
for num in a:
    if num == 0:
        dp[num] += 1
        dp[num + 1] += 1
    elif a == 100000:
        dp[num] += 1
        dp[num - 1] += 1
    else:
        dp[num] += 1
        dp[num + 1] += 1
        dp[num - 1] += 1
print(max(dp))

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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  ll odd = 0;
  rep(i,n) {
    cin >> a[i];
    if (a[i] % 2 == 1) {
      odd++;
    }
  }

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

}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys
import os
from collections import defaultdict



alphabets = 'abcdefghijklmnopqrstuvwxyz'
d = defaultdict(int)

for s in sys.stdin:
    for c in s:
        c2 = c.lower()
        if c2 in alphabets:
            d[c2] += 1

for c in alphabets:
    print('{} : {}'.format(c, d[c]))

Measured memory_bytes: 7736
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    var n = parseInt(input, 10);
    var kami = parseInt(n/2,10);
    var amari = n%2;

	//出力
	console.log('%d',kami+amari);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=a;i<b;i++)
#define eb emplace_back
#define mp make_pair
typedef long long int lli;
typedef unsigned long long int ulli;
const int INF=INT_MAX;
const lli MOD=10e8+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(30);
	int m,n;cin>>n>>m;
	char a[n+1][m+1];
	lli dp[n+1][m+1];
	forr(i,0,n+1) forr(j,0,m+1)	{a[i][j]=0;dp[i][j]=0;}
	
	
	forr(i,1,n+1)	forr(j,1,m+1)	cin>>a[i][j];
	
	
	forr(i,1,n+1)	if(a[i][1]!='#')	dp[i][1]=1; else break;
	forr(i,1,m+1)	if(a[1][i]!='#')	dp[1][i]=1; else break;
	//~ forr(i,1,n+1)	{forr(j,1,m+1)	cout<<dp[i][j]<<" ";cout<<endl;}
	forr(i,1,n+1)
	{
		forr(j,1,m+1)
		{
			if(a[i][j]!='#' && i-1>0 && j-1>0)	
			{
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				if(dp[i][j]>MOD)	dp[i][j]-=MOD;
			}
		}
	}
	
	//~ forr(i,1,n+1)	{forr(j,1,m+1)	cout<<dp[i][j]<<" ";cout<<endl;}
	cout<<dp[n][m]%MOD<<endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0; i<n; i++){
        if(i%2==0){
            if(s.at(i)!= 'R' and s.at(i)!='U' and s.at(i)!='D'){
                cout << "No" <<endl;
                return 0;
            }
        }
        if(i%2==1){
            if(s.at(i)!= 'L' and s.at(i)!='U' and s.at(i)!='D'){
                cout << "No" <<endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
#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;
    for(int i = 0; i + 1 < S.size(); ++i) {
        if(S.substr(i,2)=="AC") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = [list(map(int, input().split())) for i in range(n)]
    s = sorted(a, key=lambda x:x[1])

    t = 0
    for i in range(n):
        t += s[i][0]
        if t > s[i][1]:
            print('No')
            return
    print('Yes')
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 89592
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  int N;
  in(N);
 vl A(N);
  rep(i,N) in(A[i]);
  int ans =0;
	int su =1;
rep(i,N){
 if(A[i] == su) su++;
  else ans++;
}

if(ans != N){
out(ans);
}
else out(-1);
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

typedef long long ll;

#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;
 

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
ll a[212345];
ll x;
ll y;
ll num;
ll ans = mod*mod;

int main(){
	
	cin>>N;

	x = 0;
	y = 0;
	
	
	REP( i, N ){
		scanf("%lld", a+i);
		y += a[i];
	}
	
	
	
	REP( i, N-1 ){
		y -= a[i];
		x += a[i];
		num = x-y;
		if( num < 0 ) num *= -1;
		ans = min( ans, num );
	}
	
	cout<<ans<<endl;
	
	return 0;

}

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

#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif


// Returns a const char* representation of a container, such as a vector.
// Works for a container whose iterator has begin() and end()
string toString(auto v) {
  stringstream ss;
  ss << "[";
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin())  ss << ", ";
    ss << *it;
  }
  ss << "]";
  return ss.str();
}

vector<ll> toVector(auto q)
{
  vector<ll> v;
  while (!q.empty()) {
    v.push_back(q.top());
    q.pop();
  }
  return v;
}


ll Q;
vector<ll> p;
priority_queue<ll> small;
priority_queue<ll, vector<ll>, greater<ll>> large;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> Q;

  ll minX;
  ll minF;
  ll numP = 0;
  for (ll i = 0; i < Q; i++) {
    ll t, a, b;
    cin >> t;
    if (t == 1) {
      cin >> a >> b;
      numP++;
      if (numP == 1) {
	small.push(a);
	minX = a;
	minF = b;
      }else if (numP % 2 == 0) {
	if (small.top() < a) {
	  large.push(a);
	  minF += abs(minX - a) + b;
	}else {
	  ll oldMinX = small.top();
	  large.push(oldMinX);
	  small.pop();
	  small.push(a);
	  minX = small.top();
	  minF += abs(oldMinX - a) + b;
	}
      }else if (numP % 2 == 1) {
	if (a < large.top()) {
	  small.push(a);
	  minX = small.top();
	  minF += abs(minX - a) + b;
	}else {
	  minX = large.top();
	  small.push(minX);
	  large.pop();
	  large.push(a);
	  minF += abs(minX - a) + b;
	}
      }
      DLOG("small: %s", toString(toVector(small)).c_str());
      DLOG("large: %s", toString(toVector(large)).c_str());
    }else {
      cout << minX << " " << minF << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3828
from collections import deque
que=deque([1,2,3,4,5,6,7,8,9])
k=int(input())
for i in range(k-1):
  q=que.popleft()
  #print("q",q)
  m=q%10
  #print("m",m,"que",que)
  if m==0:
    que.append(q*10)
    que.append(q*10+1)
  elif m==9:
    que.append(q*10+8)
    que.append(q*10+9)
  else:
    que.append(q*10+m-1)
    que.append(q*10+m)
    que.append(q*10+m+1)
print(que[0])

Measured memory_bytes: 11980
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if(S.substr(0, 7) == "keyence" || S.substr(S.size() - 7, 7) == "keyence") {
        cout << "YES" << endl;
    } else {
        for(int i = 1; i <= 6; i++) {
            string front = S.substr(0, i);
            string back = S.substr(S.size() - (7 - i), 7 - i);
            if(front + back == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

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

        int n = sc.nextInt();

        int[] seq = new int[n];

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

        Map<Integer, Integer> evenBucket = new HashMap<>(); // ここでのeven/oddはインデックス基準, zero-based
        Map<Integer, Integer> oddBucket = new HashMap<>();
        evenBucket.put(-1, 0);
        oddBucket.put(-1, 0);

        for (int i = 0; i < n; i += 2) {
            if (evenBucket.containsKey(seq[i])) {
                evenBucket.put(seq[i], evenBucket.get(seq[i]) + 1);
            } else {
                evenBucket.put(seq[i], 1);
            }
        }

        for (int i = 1; i < n; i += 2) {
            if (oddBucket.containsKey(seq[i])) {
                oddBucket.put(seq[i], oddBucket.get(seq[i]) + 1);
            } else {
                oddBucket.put(seq[i], 1);
            }
        }

        List<Map.Entry<Integer, Integer>> evenBucketEntries = new ArrayList<>(evenBucket.entrySet());
        Collections.sort(evenBucketEntries, new Comparator<Map.Entry<Integer, Integer>>() {
            public int compare(Map.Entry<Integer, Integer> obj1, Map.Entry<Integer, Integer> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });


        List<Map.Entry<Integer, Integer>> oddBucketEntries = new ArrayList<>(oddBucket.entrySet());
        Collections.sort(oddBucketEntries, new Comparator<Map.Entry<Integer, Integer>>() {
           public int compare(Map.Entry<Integer, Integer> obj1, Map.Entry<Integer, Integer> obj2) {
               return obj2.getValue().compareTo(obj1.getValue());
           }
        });

        int score = -1;
        int modeForEven = evenBucketEntries.get(0).getKey();
        int modeForOdd = oddBucketEntries.get(0).getKey();
        if (modeForEven == modeForOdd) {
            int score1 = evenBucketEntries.get(0).getValue() + oddBucketEntries.get(1).getValue();
            int score2 = evenBucketEntries.get(1).getValue() + oddBucketEntries.get(0).getValue();
            if (score1 > score2) {
                score = score1;
            } else {
                score = score2;
            }
        } else {
            score = evenBucketEntries.get(0).getValue() + oddBucketEntries.get(0).getValue();
        }

        System.out.println(n - score);
    }
}

Measured memory_bytes: 54008
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] str = new String[2];
        str = br.readLine().split(" ");
        
        String[] strNum = new String[2];
        strNum = br.readLine().split(" ");
        int[] num = new int[2];
        num[0] = Integer.parseInt(strNum[0]);
        num[1] = Integer.parseInt(strNum[1]);
        
        String which = br.readLine();
        
        out.println(str[0].equals(which) ? (num[0] - 1) + " " + num[1] : num[0] + " " + (num[1] - 1));
        out.close();
        
    }
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=1,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true,up,down;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      rep(i,n)cin>>a[i];
      rep(i,n-1){
        if(!up&&!down){
          if(a[i]<a[i+1])up=true;
          else if(a[i]>a[i+1])down=true;
        }
        else if(up){
          if(a[i]>a[i+1]){
            ans++;
            up=false;
            down=false;
          }
        }
        else if(down){
          if(a[i]<a[i+1]){
            ans++;
            up=false;
            down=false;
          }
        }
        /*
        cout<<a[i]<<" ";
        if(up)cout<<1;
        else cout<<0;
        cout<<" ";    
        if(down)cout<<1;
        else cout<<0;
        cout<<"\n";
        */
      }
      Cout(ans);
     

       
return 0;
}


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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 1e5+10;
const int inf = 1e10;

int dp[N],a[N],n;


void solve()
{
  cin >> n;
    
  f(i,n) cin >> a[i+1];
    
  dp[0] = dp[1] = 0;  
   
  for(int i=2;i<=n;i++)
  {
      dp[i] = inf;
      
      dp[i] = min(dp[i],dp[i-1] + abs(a[i]-a[i-1]));
      
      if(i>2) dp[i] = min(dp[i],dp[i-2] + abs(a[i]-a[i-2]));
  }   
    
  cout << dp[n];  
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static int N;
    private static int K;
    private static int[] a;

    public static void main(String[] args) {
	N = Integer.parseInt(scan.next());
	K = Integer.parseInt(scan.next());

	a = new int[N];
	for (int i = 0; i < N; i++) {
	    a[i] = Integer.parseInt(scan.next());
	}
	Arrays.sort(a);

	int needless = binarySearch(0, N);
	System.out.println(needless);
	scan.close();
    }

    private static int binarySearch(int from, int to) {
	if(from == to) return from;

	int index = (from+to)/2;
	return isNeeded(index) ? binarySearch(from, index) : binarySearch(index+1, to);
    }

    private static boolean isNeeded(int target) {

	int k = K - a[target];
	if(k < 0) {
	    return true;
	}
	    
	int index = 0;

	boolean[][] dp = new boolean[N][K];
	for (int x = 0; x < N; x++) {
	    dp[x][0] = true;
	}

	for (int x = 1; x < N; x++) {
	    if(index == target) index++;
		
	    for (int y = 0; y < K; y++) {
		if(dp[x-1][y]) {
		    dp[x][y] = true;
		    int tmp = y + a[index];
		    if(tmp < K) dp[x][tmp] = true;
		}
	    }
	    index++;
	}

	for (int y = k; y < K; y++) {
	    if(dp[N-1][y]) {
		return true;
	    }
	}
	
	return false;
    }
}


Measured memory_bytes: 219064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int N, K;
    cin >> N >> K;
    int a= 1;
    REP(i, N){
        a = min(a * 2, a + K);
    }
        cout << a << endl;

    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

vector<bool> sosuu; // ←これをグローバル変数にして１度だけ実行する
void searchSosuu(ll N) {
	for (ll i = 0; i < N; i++) {
		sosuu.emplace_back(true);
	}
	sosuu[0] = false;
	sosuu[1] = false;
	for (ll i = 2; i < N; i++) {
		if (sosuu[i]) {
			for (ll j = 2; i * j < N; j++) {
				sosuu[i * j] = false;
			}
		}
	}
}



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N, M;
	cin >> N >> M;
	vll A(M), B(M);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	ll ans = 0;
	for (int n = 0; n < M; n++)
	{

		vvll have_path(N);
		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < N; j++)
			{
				have_path[i].emplace_back(LLINF);
			}
			have_path[i][i] = 0;
		}


		for (int i = 0; i < n; i++)
		{
			have_path[A[i]][B[i]] = 1;
			have_path[B[i]][A[i]] = 1;
		}
		for (int i = n + 1; i < M; i++)
		{
			have_path[A[i]][B[i]] = 1;
			have_path[B[i]][A[i]] = 1;
		}

		for (int k = 0; k < N; k++)
		{
			for (int s = 0; s < N; s++)
			{
				for (int g = 0; g < N; g++)
				{
					have_path[s][g] = min(have_path[s][g], have_path[s][k] + have_path[k][g]);
				}
			}
		}

		bool can = true;
		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < N; j++)
			{
				if (have_path[i][j] >= LLINF)
				{
					can = false;
					break;
				}
			}
		}

		if (!can)
		{
			ans++;
		}

	}

	cout << ans;

}





Measured memory_bytes: 256
n,m = map(int,input().split())
A = [list(map(int,input().split(" "))) for i in range(n)]
X = [int(input()) for i in range(m)]

for i in range(n):
    ans = 0
    for j in range(m):
        ans += A[i][j] * X[j]
    print(ans)


Measured memory_bytes: 6012
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

void solve() {
    int n;
    cin >> n;
    long long res = 1;
    for (int i = 0; i < n; i++)
    {
        long double num;
        cin >> num;
        if (num == 0) {
            res = 0;
            break;
        }
        else if (num > ((long double) 1e18 / res)) {
            res = -1;
        }
        else {
            res *= num;
        }
    }
    cout << res << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535
 
int main() 
{
    FAST;
	ll n,m;
    cin>>n>>m;
    ll x=n*(n-1)/2,y=m*(m-1)/2;
    cout<<x+y;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace id_0336cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var height = inputs[0];
            var radius = inputs[1];
            Console.WriteLine(DayOrSunriseOrNight(height, radius));
        }
        static int DayOrSunriseOrNight(int height, int radius)
        {
            var upperPosition = height + radius;
            if(upperPosition < 0)
            {
                return -1;
            }
            if(upperPosition > 0)
            {
                return 1;
            }
            return 0;
        }
    }

}



Measured memory_bytes: 9568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A.rbegin(), A.rend());

	ll ans = A[0];//0番目 1番目が訪れた後の合計心地よさ
	for(int i=2; i<N; i++){
		int index;
		if(i%2==0) index = i/2;
		else       index = i/2;
		ans += A[index];
	}
	cout << ans << endl;

}


Measured memory_bytes: 4832
def solve():
    a, b = map(int, input().split())
    s_i, s_j = 1, 0
    t_i, t_j = 0, 1
    while b:
        q, r = divmod(a, b)
        s_i, s_j = s_j, s_i - q * s_j
        t_i, t_j = t_j, t_i - q * t_j
        a, b = b, r
    print(s_i, t_i)

solve()

Measured memory_bytes: 7784
#include<iostream>
#include<string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
    string req, s, p;
    int n, a, b;
    cin >> s;
    cin >> n;

    for (int i=0; i< n;i++){
        cin >> req >>  a >>b;
        if (req == "replace"){
            cin >>p;
            s.replace(a, b-a+1, p);
        }else if (req == "reverse"){
            string tmp = s.substr(a,b-a+1);
            reverse(tmp.begin(),tmp.end());
            s=s.substr(0,a)+ tmp+ s.substr(b+1,s.size()-a-1);
        }else{
            cout << s.substr(a,b-a+1) << endl;

        }
    }



  return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }

signed main() {
    int n;
    cin >> n;
    vector<int> as(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    int ans = 0;
    REP(i, n - 1) {
        if (as[i] == i + 1) {
            swap(as[i], as[i + 1]);
            ans++;
        }
    }
    if (as[n - 1] == n) {
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n; cin >> n;
	int cnts = 0, cntt = 0;
	string s, t;
	cin >> s >> t;
	char out[220] = "";
	int i;
	for (i = 0; i < n*2; i++)
	{
		if (i % 2 != 0) {
			out[i] = t[cntt];
			cntt++;
		}
		else {
			out[i] = s[cnts];
			cnts++;
		}
	}
	cout << out << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, result;
	LL ans = 0;
	cin >> n;
	VI numbers(n - 1);
	REP(i,n - 1){
		cin >> numbers[i];
	}
	cin >> result;

	vector<vector<LL> > dp(n-1, vector<LL>(21));
	dp[0][numbers[0]] = 1;
	REP(i, n - 2){
		REP(j, 21){
			LL value;
			if(20 >= j + numbers[i+1]){
				value = dp[i + 1][j + numbers[i+1]] += dp[i][j];
			}
			if(j - numbers[i+1] >= 0){
				value = dp[i + 1][j - numbers[i+1]] += dp[i][j];
			}
		}
	}
	cout << dp[n - 2][result] << endl;
	
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>

int main()
{
    int i;

    //標準入力
    int n;
    scanf("%d", &n);
    int a[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &a[i]);

    //標準出力
    while( i-- ){
        printf("%d", a[i]);
        if( i ) printf(" ");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ld sum = 0, n, k;cin >> n >> k;
	for(int i = 1; i <= n;i++) {
		if (i < k) {
			int o = i;ld  p = 100;
			while (o < k) {
				p /= 2;
				o *= 2;
			}
			sum += p / n;
		}
		else {
			sum += 100 / n;
		}
	}
	cout << fixed << setprecision(10) << sum / 100 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x,y,z,d;
    scanf("%d%d",&x,&y);
    
    if(x<y){
        while(x != 0){
            d=y%x;
            y=x;
            x=d;
        }
        printf("%d\n",y);
    }
    else{
    while(y !=0){
        d=x%y;
         x=y;
        y=d;
     
    }
    printf("%d\n",x);
    }
    return 0;
}


Measured memory_bytes: 2072
#include <cstdio>
#include <iostream>
#include <string.h>
using namespace std;

int main(){
		string s;
		int leng;
		int count=0;
		cin >> s;
		leng = s.length();
				for(int i=0;i<leng;i++){
						if(i==0 && s[i]=='A'){
								continue;
						}

						else if(i==0 &&s[0]!='A')  {
								cout << "WA" << endl;
								return 0;
						}
						
						if(s[i]== 'C'){
								if(2<=i && i <= leng-2){
										count++;
								}

								else {
									cout << "WA" << endl;
									return 0;
								}
						}
						else{
								if('a'>s[i] || s[i]>'z'){
									cout << "WA" << endl;
									return 0;
								}
						}
				}
				if(count == 1){
						cout << "AC" << endl;
						return 0;
				}
				cout << "WA" << endl;
				return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,j,N;
	scanf("%d",&N);
	for(j=0;j<N;j++){
		scanf("%d%d%d",&a,&b,&c);
		if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b){
		printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    string S[h][w];
    REP(i, h) REP(j, w) cin >> S[i][j];

    char a;
    int b;
    REP(i, h){
        REP(j, w){
            if(S[i][j] == "snuke"){
                a = 'A' + j;
                b = i + 1;
                break;
            }
        }
    }
    cout << a << b << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

r = S.count('R')
g = S.count('G')
b = S.count('B')

cnt = 0
for i in range(N-3):
    if S[i] == 'R':
        r -= 1
        cnt += g * b 
        l = 1
        while (i + 2 * l < N):
            if (S[i+l] == 'G' and S[i+2*l] == 'B') or (S[i+l] == 'B' and S[i+2*l] == 'G'):
                cnt -= 1
            l += 1
    if S[i] == 'G':
        g -= 1
        cnt += r * b 
        l = 1
        while (i + 2 * l < N):
            if (S[i+l] == 'R' and S[i+2*l] == 'B') or (S[i+l] == 'B' and S[i+2*l] == 'R'):
                cnt -= 1
            l += 1
    if S[i] == 'B':
        b -= 1
        cnt += g * r
        l = 1
        while (i + 2 * l < N):
            if (S[i+l] == 'G' and S[i+2*l] == 'R') or (S[i+l] == 'R' and S[i+2*l] == 'G'):
                cnt -= 1
            l += 1
print(cnt)


Measured memory_bytes: 9292
import qualified Data.Vector.Unboxed as V

main = getLine >>= print.solve.map read.words
solve [n, k]
  | k >= n - 1 = part n n
  | otherwise = foldl1 (+%) [ comb n k *% part k (n-k) | k <- [0..k] ]

mo = 10^9 + 7 :: Int
a ^% b
  | b < 0 = 0
  | b == 0 = 1
  | otherwise = f a b
  where
    f a b
      | even b = f (a *% a) (quot b 2)
      | b == 1 = a
      | otherwise = g (a *% a) (quot b 2) a
    g a b c
      | even b = g (a *% a) (quot b 2) c
      | b == 1 = a *% c
      | otherwise = g (a *% a) (quot b 2) (a *% c)
a *% b = rem (a * b) mo
a /% b = a *% (b ^% (mo - 2))
factt = V.fromList $ scanl (*%) 1 [1..400000]
fact = (factt V.!)
comb a b = fact a /% fact b /% fact (a-b)
a -% b = rem (mo + a - b) mo
a +% b = rem (a + b) mo
part a b = fact (a+b-1) /% fact a /% fact (b-1)

Measured memory_bytes: 37244
#include <stdio.h>
#include <string.h>
int a1,a2,a3,a4,d[16],n;;
char node[20],s[100];
evaluate(char s[],int d[])
{ int ret,d1[16],d2[16],lv,len;
  int i,j;
  char *p,*q; 
  memset(d,0,sizeof(d1));
  memset(d1,0,sizeof(d1));
  memset(d2,0,sizeof(d2));
  if((ret=atoi(s))>0) 
    { d[node[ret]]=1;
      return;
    }
  lv=0;len=strlen(s);
  for(p=s;*p;p++)
     if(*p=='(')
	lv++;
      else if(*p==')')
	lv--;
      else if(lv==1 && *p==' ')
	{ q=p;
	  break;
	}
  *q='\0';
  evaluate(s+1,d1); 
  s[len-1]='\0';
  evaluate(p+1,d2);     
  for(i=0;i<16;i++)
    for(j=0;j<16;j++)
      d[i&j]+=d1[i]*d2[j],d[i|j]+=d1[i]*d2[j],d[i^j]+=d1[i]*d2[j];
}
main()
{
  int i,ret;
  while(fgets(s,100,stdin) && *s != 'E')
    { scanf("%d",&n);
      for(i=1;i<=n;i++)
	{ scanf("%d %d %d %d ",&a1,&a2,&a3,&a4);
	  node[i]=8*a1+4*a2+2*a3+a4;
	}
      evaluate(s,d);
      printf("%d\n",d[15]);
      memset(s,0,sizeof(s));
    }
  return(0);
}

Measured memory_bytes: 616
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    map<char,set<int>> st;
    for(int i=0;i<s.size();i++){
        st[s[i]].insert(i);
    }
    for(int i=0;i<t.size();i++){
        if(st[t[i]].empty()){
            cout<<-1;
            return 0;
        }
        if(st[t[i]].lower_bound(b)==st[t[i]].end()){
            a++ , b = 0;
        }
        b = *st[t[i]].lower_bound(b);
        b++;
    }
    cout<<(a*s.size()+b);
    return 0;
}
//.........

Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    if ( b < a ) cout << 0 << endl;
    else if ( n == 1 ) {
        if ( a != b) cout << 0 << endl;
        else         cout << 1 << endl;
    }
    else {
        cout << ( n - 2 ) * ( b - a ) + 1 << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<P> vec;
int n;

int main()
{
	scanf("%d",&n);
    if(n % 2){
        printf("NA\n");
        return 0;
    }
	rep(i,n){
        int x,y;
		scanf("%d%d",&x,&y);
        vec.push_back(P(x,y));
	}
    P cent = P(vec[0].first + vec[n/2].first,vec[0].second + vec[n/2].second);
    bool flag = false;
    for(int i = 1;i < n/2; i++){
        P p = P(vec[i].first + vec[n/2 + i].first,vec[i].second + vec[n/2 + i].second);
        if(cent != p){
            flag = true;
            break;
        }
    }
    if(flag){
        printf("NA\n");
    }else{
        printf("%.5f %.5f\n",cent.first / 2.0,cent.second / 2.0);
    }
	return 0;
}

Measured memory_bytes: 3208
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] A = new int[3][3];
		for(int i =0; i<3 ; i ++) {
			for(int j =0; j<3 ; j ++) {
				A[i][j] = sc.nextInt();
			}
		}
		int N = sc.nextInt();
		int[] b = new int[N];
		int[][] checkA = new int[3][3];
		for(int k=0; k < N; k++) {
			b[k] = sc.nextInt();
			for(int i =0; i<3 ; i ++) {
				for(int j =0; j<3 ; j ++) {
					if(A[i][j] == b[k]) checkA[i][j] = 1;
				}
			}
		}

		boolean ans = false;
		for(int i =0; i<3 ; i ++) {
			int checkSum = 0;
			for(int j =0; j<3 ; j ++) {
				checkSum += checkA[i][j];
			}
			if(checkSum == 3)  ans = true;
		}

		for(int i =0; i<3 ; i ++) {
			int checkSum = 0;
			for(int j =0; j<3 ; j ++) {
				checkSum += checkA[j][i];
			}
			if(checkSum == 3)  ans = true;
		}

		int checkSum = 0;
		for(int j =0; j<3 ; j ++) {
			checkSum += checkA[j][j];
		}
		if(checkSum == 3)  ans = true;
		
		checkSum = 0;
		for(int j =0; j<3 ; j ++) {
			checkSum += checkA[j][2-j];
		}
		if(checkSum == 3)  ans = true;
		
		if(ans) System.out.println("Yes");
		else System.out.println("No");




	}
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(){
    int n,m,i;
    scanf("%d %d",&n,&m);
    int a[1001],all=0,count=0;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        all+=a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]*4*m>=all){
            count++;
        }
    }
    if(count>=m)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>

using namespace std;

int main() {
    int n, k;
    int h[100001];
    cin >> n >> k;
    int i, j;
    for(i = 0; i < n; i++) {
        cin >> j;
        h[i] = j;
    }
    int dp[n];
    int min, tmp;
    dp[0] = 0;
    for(i = 1; i <= k && i < n; i++) {
        for(j = 0; j < i; j++) {
            if(j == 0) {
                min = abs(h[i] - h[j]);
            } else {
                tmp = dp[j] + abs(h[i] - h[j]);
                if(tmp < min) {
                    min = tmp;
                }
            }
        }
        dp[i] = min;
    }

    for(i = 0; i < n - k; i++) {
        min = -1;
        for(j = 0; j < k; j++) {
            if(min < 0) {
                min = dp[i+j] + abs(h[i+j] - h[i+k]);
            } else {
                tmp = dp[i+j] + abs(h[i+j] - h[i+k]);
                if(min > tmp) {
                    min = tmp;
                }
            }
        }
        dp[i+k] = min;
    }
    
    cout << dp[n-1] << endl;

    //for(i = 0; i < n;i++) cout << dp[i] << " ";
    //cout << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<cstring>
#include <cmath>
#include <cstdio>
#include<cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
using namespace std;
#define MOD 1000000007
map<long long,long long>ma;
char a[100005];

int main() {

 long n,m,res[200005],i,j,temp,len;
   
    string s="CODEFESTIVAL2016",x;
    len=s.length();
    cin>>x;
    long long count=0;
    for(i=0;i<len;i++)
        if(x[i]!=s[i])
        count++;
        cout<<count;

}

Measured memory_bytes: 256