akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
struct tree {
  int data;
  struct tree *left;
  struct tree *right;
};
struct tree *sentinel, *root;
int Search(struct tree*, int);
struct tree *Insert(struct tree*, int);
struct tree *Alsearch(struct tree**);
struct tree *Remove(struct tree**, int);
void Dispm(struct tree*);
void Dispp(struct tree*);
int main(void)
{
  int i, count, key;
  char command[7];
  sentinel = (struct tree*)malloc(sizeof(struct tree));
  root = sentinel;
  scanf("%d", &count);
  for (i = 0; i < count; i++) {
    scanf("%*c%s", command);
    switch (command[0]) {
    case 'f':
      scanf(" %d", &key);
      sentinel -> data = key;
      if (Search(root, key)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
      break;
    case 'i':
      scanf(" %d", &key);
      sentinel -> data = key;
      root = Insert(root, key);
      break;
    case 'd':
      scanf(" %d", &key);
      sentinel -> data = key;
      Remove(&root, key);
      break;
    case 'p':
      Dispm(root);
      putchar('\n');
      Dispp(root);
      putchar('\n');
      break;
    }
  }
  return 0;
}
int Search(struct tree *p, int key)
{
  if (p -> data > key) {
    return Search(p -> left, key);
  } else if (p -> data < key){
    return Search(p -> right, key);
  }
  if (p == sentinel) return 0;
  else return 1;
}
struct tree *Insert(struct tree *p, int key)
{
  if (p -> data > key) {
    p -> left = Insert(p -> left, key);
  } else if (p -> data < key) {
    p -> right = Insert(p -> right, key);
  }
  else {
    p = (struct tree*)malloc(sizeof(struct tree));
    p -> data = key;
    p -> left = sentinel;
    p -> right = sentinel;

  }
  return p;
}
struct tree *Alsearch(struct tree **p)
{
  if ((*p) -> left == sentinel) {
    struct tree *tmp = *p;
    *p = (*p) -> right;
    return tmp;
  } else {
    return Alsearch(&(*p) -> left);
  }
}

struct tree *Remove(struct tree **p, int key)
{
  if ((*p) -> data > key) {
    (*p) -> left = Remove(&(*p) -> left, key);
  } else if ((*p) -> data < key) {
    (*p) -> right = Remove(&(*p) -> right, key);
  } else {
    struct tree *tmp = *p;
    if (*p == sentinel) return sentinel;
    if ((*p) -> right == sentinel) {
      *p = (*p) -> left;
      free(tmp);
    }else if ((*p) -> left == sentinel) {
      *p = (*p) -> right;
      free(tmp);
    } else {
      struct tree *alter = Alsearch(&(*p) -> right);
      alter -> left = (*p) -> left;
      alter -> right = (*p) -> right;
      *p = alter;
      free(tmp);
    }
  }
  return *p;
}
void Dispm(struct tree *p)
{
  if (p != sentinel) {
    Dispm(p -> left);
    printf(" %d", p -> data);
    Dispm(p -> right);
  }
}
void Dispp(struct tree *p)
{
  if (p != sentinel) {
    printf(" %d", p -> data);
    Dispp(p -> left);
    Dispp(p -> right);
  }
}


Measured memory_bytes: 14192
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define eb emplace_back
#define emp emplace
#define ss second
#define ff first
#define endl "\n"
#define PI 3.14159265359
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

void reads(string& x){
    char kk[N];
    scanf("%s",kk);
    x = kk;
}
ll n, val;
ll ans;
map<ll,ll> m;
void solve(){
    scanf("%lld", &n);
    forn(i,0,n){
        scanf("%lld",&val);
        ans+=m[i-val];
        m[i+val]++;
    }
    printf("%lld\n",ans);
}
int main(){_
    int t=1;// scanf("%d",&t);
    while(t--){
        solve();
    }
}

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

int main()
{
    int N;
    string A, B, C;
    cin >> N;
    cin >> A >> B >> C;
    int operations = 0;
    for (int i = 0; i< N; i++) {
        if (A[i] != C[i])
            operations++;
        if (A[i] != B[i]) {
            if (B[i] != C[i])
                operations++;
        }
    }
    cout << operations;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 28 21:00:07 JST 2020
 **/

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

signed main() {
    Int K, n;
    std::cin >> K >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    Int ma = 0;
    REP(i, n) {
        Int tmp = i == n - 1 ? a[0] + K : a[i + 1];
        chmax(ma, tmp - a[i]);
    }
    std::cout << K - ma << std::endl;
}


Measured memory_bytes: 1792
N,K = list(map(int, input().split()))
P = list(map(int, input().split()))

cumsum = [0] * (N+1)

for i in range(N):
  cumsum[i+1] = cumsum[i] + P[i]
  
ans = -99
for i in range(N-K+1):
  ans = max(cumsum[i+K] - cumsum[i], ans)
  
print((ans + K)/2)

Measured memory_bytes: 25060
def main():
  s = list(input())
  ans = 0
  ansma = 0
  for i in s:
    if i == "R":
      ans += 1
    else:
      ans = 0
    if ans >= ansma:
      ansma = ans
  print(ansma)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
int x, a, b;

int main() {
	cin >> x >> a >> b;
	int l1 = abs(x - a);
	int l2 = abs(x - b);
	if(l1 < l2) puts("A");
	else if(l1 > l2) puts("B");
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/12/01.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CYESA cout<<"Yay!"<<endl
#define CNOA cout<<":("<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    rep(i,n+1){
        if(i*108/100==n){
            cout << i << endl;
            return 0;
        }
    }
    CNOA;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
char s[55];
int ans[55][55],b[55][55];
int mvx[9]={0,1,-1,0,0,1,-1,1,-1},mvy[9]={0,0,0,1,-1,1,-1,-1,1};
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) {
		scanf("%s",s);
		for(int j=0;j<m;++j) b[i][j+1]=(s[j]=='#');
	}
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=m;++j) {
			if(b[i][j]){putchar('#');continue;}
			for(int k=1;k<=8;++k) ans[i][j]+=b[i+mvx[k]][j+mvy[k]];
			printf("%d",ans[i][j]);
		}
		putchar('\n');
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define For(I,X,Y) for(LL I=(X);I<=(Y);I++)
#define ForDown(I,X,Y) for(LL I=(X);I>=(Y);I--)
using namespace std;

inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}

char CH[105];
LL N,Ans;

int main(){
	scanf("%s",CH+1);N=Read();
	
	For(I,1,N) if(CH[I]!='1') {putchar(CH[I]);return 0;}
	
	puts("1");
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

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

    ll n, m; cin>>n>>m;
    ll x, sum = 0;
    loop(m){
        cin>>x;
        sum += x;
    }
    if(sum>n) return cout<<"-1\n", 0;
    else cout<<n-sum<<"\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s,t;
	cin >> s >> t;
	int n = s.length(),m = t.length(),ans = INF;
	for(int i = 0;i < n - m + 1;i++){
		int cnt = 0;
		for(int j = 0;j < m;j++){
			if(s[i + j] != t[j]) cnt++;
		}
		chmin(ans,cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    string s;
    cin>>s;
    rep(i,s.size())
    {
        if(s[i]=='7')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MAXN 510000
#define ll long long
#define INF (1ll<<60) 
using namespace std;
ll n,q;
struct dataa{
	ll u,v,w;
}line[MAXN*2];

ll link[MAXN*2];

inline ll read(){
    ll 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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

inline bool cmp(dataa a,dataa b){
	return a.w<b.w;
}

ll fa[MAXN];

ll find(ll x){
	if (fa[x]==x)
		return x;
	return fa[x]=find(fa[x]);
}
int main(){
	n=read(),q=read();
	for(ll i=0;i<2*n;i++)
		link[i]=line[q+i].w=INF;
	for(ll i=1;i<=q;i++){
		ll a=read(),b=read(),c=read();
		line[i].u=a,line[i].v=b,line[i].w=c;
		
		link[a]=min(link[a],c+1);
		link[b]=min(link[b],c+2);
	}
	ll minn=INF;
	for(ll i=0;i<2*n-1;i++){
		minn+=2;
		minn=min(link[i],minn);
		line[q+(i%n)+1].u=i%n;
		line[q+(i%n)+1].v=(i+1)%n;
		line[q+(i%n)+1].w=min(line[q+(i%n)+1].w,minn);
	}
	sort(line+1,line+1+n+q,cmp);
	ll cnt=0,sum=0;
	for(int i=0;i<n;i++)
		fa[i]=i; 
	for(ll i=1;cnt<n-1;i++){
		ll xf=find(line[i].u),yf=find(line[i].v);
		if (xf!=yf){
			//cout<<line[i].u<<" "<<line[i].v<<" "<<line[i].w<<endl;
			cnt++;
			fa[xf]=yf;
			sum+=line[i].w;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 22836
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int t[20][20];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  R(i,n){
    LD d;
    cin >> d;
    int x = round(d * 1e9);
    int il2 = 0;
    while(x % 2 == 0){
      x/=2;
      il2++;
    }
    int il5 = 0;
    while(x % 5 == 0){
      x/=5;
      il5++;
    }
    debug(il2,il5);
    t[min(il2,18ll)][min(il5,18ll)]++;
  }
  int res = 0;
  R(i,19)R(ii,19)R(j,19)R(jj,19){
    if(i + ii >= 18 && j + jj >= 18){
      res += t[i][j] * t[ii][jj];
      if(i == ii && j == jj){
        res -= t[i][j];
      }
    }
  }
  res /= 2;
  cout << res << "\n";
}


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

int main(){
    using namespace std;
    unsigned long H;
    cin >> H;
    H |= H >> 1;
    H |= H >> 2;
    H |= H >> 4;
    H |= H >> 8;
    H |= H >> 16;
    H |= H >> 32;
    cout << H << endl;
    return 0;
}

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

int main() {
	int a, b; cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;

	if (a > b) cout << "Alice" << endl;
	else if (a < b) cout << "Bob" << endl;
	else cout << "Draw" << endl;
	
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main(){
  var A,B,C,D int
  fmt.Scan(&A,&B,&C,&D)
  fmt.Println(min(A,B)+min(C,D))
}

func min(A int, B int)int{
  if A<=B{
    return A
  }else{
    return B
  }
}


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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
const int N=100005;
const int inf=1e18;
const double eps=1e-9;

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
            res=res*a;
            res%=mod;
        }
        a=a*a;
        a%+mod;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    int c=1;
    int p=26;
    int i=0;
    while(c<=n){
        // int ta=c*26;
        c+=p;
        p=p*26;
        i++;
    }
    // c-=p;
    p=p/26;
    c-=p;
    p=p/26;
    // o2(c,p);
    // int i=sqrt(p);
    // i++;
    // o1(i);
    // return 0;
    // int d=n-c
    // c-=p;
    // o2(c,p);
    int d=n-c;
    int l=0;
    while(l<i){
        int f=d/p;
        cout<<(char)('a'+f);
        d=d-f*p;
        p=p/26;
        l++;
    }






	
return 0;
}


Measured memory_bytes: 3628
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
//作者：中国江苏南京朱泽齐
bool good[10][10];
int n,a[10]={1,2,3,4,5,6,7,8,9,10};
bool check(){
	for(int i=0;i<n-1;i++)
	if(!good[a[i]][a[i+1]])
	return false;
	return true;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int m,x,y,ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		good[x][y]=good[y][x]=true;
	}
	do{
		if(check())
		ans++;
	}while(next_permutation(a+1,a+n));
	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
#define mod 1000000007
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	long long int N,K;
	cin>>N>>K;
	long long int coo=0;
	long long int co=0;
	long long int ans;
	 if(2*N<K){
		cout<<0<<endl;
    	return 0;
  	}
	else if(K%2==1){
		co=N/K;
		ans=co*co*co;
	}
	else{
		co=N/K;
		coo=(N-K/2)/K+1;
		//cout<<co<<endl;
		ans=co*co*co+coo*coo*coo;
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]

from collections import defaultdict

used = defaultdict(bool)

prev = W[0][0]

flag = True
for w in W:
    if not used[w] and w[0] == prev:
        used[w] = True
        prev = w[-1]
    else:
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
int main()
{
    char ch[20];
    gets(ch);
    if(0==strcmp(ch,"Sunny"))
    printf("Cloudy\n");
    else if(0==strcmp(ch,"Cloudy"))
        printf("Rainy\n");
    else if (0==strcmp(ch,"Rainy"))
        printf("Sunny\n");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>T&get(){T a;cin>>a;return a;}
template<typename T>T&rev(T&a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>a){sort(all(a));return a;}

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

const int inf = 1e9;
const ll linf = 3e18;

int d[100001];

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

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

    rep1(i, N - 1) {
        int s; cin >> s;
        d[i] = s + d[i - 1];
    }

    int ans = 0;

    int now = 0;

    rep1(i, M) {
        int a; cin >> a;
        int nxt = now + a;
        ans += d[max(now, nxt)] - d[min(now, nxt)];
        ans %= 100000;
        now = nxt;
    }

    cout << ans << endl;
}

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

int main(int argc, char **argv)
{
	ll n;
  cin>>n;
  ll sum=0;
  for  (ll i=1;i<=n;i++){
    sum+=i;
  }
  cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
    vector<int> va(N);
    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N; ++i) {
        va.at(i) = -1;
    }
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
            va.at(nv) = v;
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout << "Yes" << endl;
    for(int i = 1; i < N; ++i){
        cout << va.at(i)+1 << endl;
    }
}

Measured memory_bytes: 10724
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int bound(int k, int N, int *b){
	int l = -1, h, r = N;
	while(r - l > 1){
		h = (l + r) / 2;
		if(b[h] < k){
			l = h;
		}
		else{
			r = h;
		}
	}
	return r;
}

signed main(){
	int N, i, j, ans = 0, xor, bound1, bound2, bound3;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	for(i = 0; i < N; i++){
		scanf("%lld", &b[i]);
	}
	for(i = 28; i >= 0; i--){
//		printf("i = %d\n", i);
		for(j = 0; j < N; j++){
			a[j] &= (1 << (i + 1)) - 1;
			b[j] &= (1 << (i + 1)) - 1;
		}
		sort(b, N);
/*		for(j = 0; j < N; j++){
			printf("b[%d] = %d\n", j, b[j]);
		}
*/		bound1 = 0;
		bound2 = 0;
		bound3 = 0;
		for(j = 0; j < N; j++){
			bound1 += bound(1 * (1 << i) - a[j], N, b);
			bound2 += bound(2 * (1 << i) - a[j], N, b);
			bound3 += bound(3 * (1 << i) - a[j], N, b);
		}
//		printf("bound1 = %d\n", bound1);
//		printf("bound2 = %d\n", bound2);
//		printf("bound3 = %d\n", bound3);
		xor = (N - bound3 + bound2 - bound1) & 1;
//		printf("xor = %d\n", xor);
		ans |= (xor << i);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    
    
    int k;
    cin >> k;
    vector<int> a(k);
    rep(i, k) cin >> a[i];
    
    ll u = 2, d = 2;
    for (int i = k - 1; i >= 0; --i) {
        ll x = (d + (a[i] - 1)) / a[i] * a[i];
        ll y = u / a[i] * a[i] + (a[i] - 1);
        u = y;
        d = x;
    }
    if (d > u) out(-1);
    else out(d << " " << u);
}


Measured memory_bytes: 640
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
		a: [isize; n],
	}

	let mut ans = 0;
	for i in 0..n-1 {
		for j in i..n {
			ans = max(ans, (a[i]-a[j]).abs());
		}
	}

	println!("{}", ans);
}


Measured memory_bytes: 2184
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();

            int ans = 700;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'o') {
                    ans += 100;
                }
            }

            System.out.println(ans);
        }
    }

}


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

int main(void){
    ll k,a,b,res;
    cin>>k>>a>>b;
    if(a>=k) res = 1;
    else if(a<=b) res = -1;
    else{
        ll x = (k-a)/(a-b);
        res = x*2;
        if(x*(a-b)>=k);
        else if(x*(a-b)+a>=k) res += 1;
        else res += 3;
    }
    cout<<res<<endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int ans;
  if(S=="SUN"){
    ans = 7;
  }else if(S=="MON"){
    ans = 6;
  }else if(S=="TUE"){
    ans = 5;
  }else if(S=="WED"){
    ans = 4;
  }else if(S=="THU"){
    ans = 3;
  }else if(S=="FRI"){
    ans = 2;
  }else if(S=="SAT"){
    ans = 1;
  }
  cout << ans<< endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

class AColorfulSlimes2 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in>>n;
		int arr[n];
		f(i, n) in>>arr[i];
		int res = 0;
		int i = 0;
		while(i<n){
			int cur = arr[i];
			int cnt = 0;
			while(i<n and arr[i] == cur) ++i, ++cnt;
			res += (cnt/2);
		}
		out<<res;
	}
};


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	AColorfulSlimes2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll a,b,c,d,ans=0,i,e[101]={0};
	cin>>a>>b>>c>>d;
	for (i=a;i<b;i++){
		e[i]++;
	}
	for (i=c;i<d;i++){
		e[i]++;
	}
	for (i=0;i<100;i++){
		if (e[i]==2){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

const int MAXN = 100010;
int A[MAXN];
ll cnt[MAXN];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	vector<pii> P(N);
	for (int i = 0; i < N; i++) {
		P[i] = pii(A[i], i);
	}
	sort(P.rbegin(), P.rend());
	int mini = N;
	for (int i = 0; i < N; ) {
		int ni = i;
		while (ni < N && P[i].first == P[ni].first) {
			mini = min(mini, P[ni].second);
			++ni;
		}
		int next = 0;
		if (ni < N) next = P[ni].first;
		ll diff = P[i].first-next;
		cnt[mini] += diff*ni;
		i = ni;
	}
	for (int i = 0; i < N; i++) {
		cout << cnt[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
	int n;
	cin>>n;
	pair<ll,ll>a[n];
	rep(i,n)cin>>a[i].second>>a[i].first;
	sort(a,a+n);
	ll time=0;
	bool flag=true;
	rep(i,n){
		time+=a[i].second;
		if(time > a[i].first){
			flag=false;
			break;
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

int main(void){
  long long a,b,k;
  
  cin >> a >> b >> k;
  if (k>=a){
    k-=a;
    a=0;
  } else{ // k<a
    a -= k;
    k=0;
  }
  if (k>=b) b=0;
  else b -= k;
  cout << a << " " << b << endl;
 
  return 0;
}


Measured memory_bytes: 256
# -*- coding: UTF-8 -*-
#Bubble Sort

#標準入力から
N = int(input()) #要素数
A = list(map(int,input().split())) #ソート対象（スペース区切り→配列に展開）

#print('input')
#print(N)
#print(A)

flag = 1
i = 0
cnt = 0

#Sort処理（自分メモ：flagが0になったらループを抜ける）
while flag:
    flag = 0
    for j in reversed(range(i+1,N)):
        if A[j] < A[j-1]:
            tmp = A[j-1]
            A[j-1] = A[j]
            A[j] = tmp
            flag = 1
            cnt += 1
    i += 1

#print('output')
#print(A)
print(' '.join(map(str,A)))
print(cnt)



Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int N;
    cin >> N;
    int counter = 0;
    for(int a = 1; a < N+1; a++){
        int yakusu_counter = 0;
        if(a%2 == 1){
            for(int i = 1; i < a+1; i++){
            if(a%i == 0){
                yakusu_counter++;
            }
        }
        if(yakusu_counter == 8){
            counter++;
        }
        }
    }

    cout << counter << endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int n,m,x,y;
  bool a[200010]={ 0 }, b[200010]={ 0 };
  cin>>n>>m;
  
  for(int i=0;i<m;i++){
  	cin>>x>>y;
  	if(x==1) a[y]=1;
  	if(y==n) b[x]=1;
  }
  
  for(int i=2;i<=n;i++){
  	if(a[i]==1 && b[i]==1) {
  		cout<<"POSSIBLE"<<endl;
		return 0;	
	}
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
    public static long solve(int arr[], int n, int k) {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Integer.MAX_VALUE;
            for (int j = 1; j <= k && (i - j) >= 1; j++) {
                ans[i] = Math.min(ans[i], Math.abs(arr[i] - arr[i - j]) + ans[i - j]);
            }
            // ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i]
            // - arr[i - 2]) + ans[i - 2]);
        }
        return ans[n];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int arr[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(solve(arr, n, k));
    }
}

Measured memory_bytes: 50076
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	vector<int> a(3);
	rep(i, 3)
		cin >> a[i];
	sort(all(a));
	cout << a[2] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	int n, sum, elmNum[ 9 ] = { 5, 3, 3, 3, 3, 3, 4, 3, 4 };
	char ch[ 9 ][ 6 ] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }, key, tmp;

	scanf( "%d ", &n );
	while ( n-- ) {
		while ( ( key = getchar() ) != '\n' ) {
			if ( key == '0' )
				continue;

			for ( sum = 0; ( tmp = getchar() ) != '0'; sum++ ) ;

			putchar( ch[ key - '1' ][ sum % elmNum[ key - '1' ] ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 564
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, d = 0, s = 0;
    cin >> n >> k;
    int a[n], p[n];
    for (int i = 0; i < n; i++) 
    {
        cin >> a[i];
        p[i] = 0;
    }
    p[0] = 1;
    sort(a, a + n);
    for (int i = 1; i < n; i++)
    {
        if (a[i] != a[i - 1]) 
        {
            d++;
            p[d] = 1;
        }
        else p[d]++;
    }
    d++;
    if (d <= k) cout << '0';
    else
    {
        d -= k;
        sort(p, p + n);
        k = 0;
        for (int i = 0; i < n; i++)
        {
            if (p[i] > 0)
            {
                s += p[i];
                k++;
            }
            if (k == d) break;
        }
        cout << s;
    }
}

Measured memory_bytes: 5088
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner reader=new Scanner(System.in);
		String c=reader.next();
		String f=reader.next();
		String d=reader.next();
		
		System.out.print(c.charAt(0) ); 
		System.out.print(f.charAt(0) );
		System.out.print(d.charAt(0) );
	}
	
	

}


Measured memory_bytes: 22996
#include<iostream>

int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    int N;std::cin >> N;
    int a,ans=0;
    for (int i=1;i<=N;++i){
        std::cin >> a;
        if ( i % 2 != 0 && a % 2 !=0 ) {
            ++ans;
        }
    }
    std::cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s,n,sum=0;cin>>s>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
	cin>>arr[i];
	sum+=arr[i];
   }
   if(s<sum)
   cout<<"-1"<<" ";
   else 
   cout<<s-sum<<endl;
   return 0;
	
	
}

Measured memory_bytes: 3620
# 最長共通部分列

def lcs(x, y):
    m = len(x)
    n = len(y)
    c = [0] * (n + 1)
    for i in range(m):
        c2 = c[:]
        for j in range(n):
            if x[i] == y[j]:
                c[j + 1] = c2[j] + 1
            elif c[j + 1] < c[j]:
                c[j + 1] = c[j]
    return c[-1]


n = int(input())
Z = [0] * n
for i in range(n):
    X = input()
    Y = input()
    Z[i] = lcs(X, Y)
for z in Z:
    print(z)



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    if (M % 2) {
        rep(j, M / 2)
        {
            cout << j + 1 << ' ' << M - j << endl;
        }

        rep(j, M / 2 + 1)
        {
            cout << j + M + 1 << ' ' << 2 * M + 1 - j << endl;
        }
    } else {
        rep(j, M / 2)
        {
            cout << j + 1 << ' ' << M - j << endl;
        }

        rep(j, M / 2)
        {
            cout << j + M + 1 << ' ' << 2 * M + 1 - j << endl;
        }
    }
}


Measured memory_bytes: 3636
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  let WHN = input[0].split(' ').map(Number);
  let minX = 0;
  let minY = 0;
  let maxX = WHN[0];
  let maxY = WHN[1];
  const N = WHN[2];

  for(let i=1; i<=N; i++){
    let tmp = input[i].trim().split(' ').map(Number)
    let A = tmp[2];
    if(A === 1){
      if(tmp[0] > minX){
        minX = tmp[0];
      }
    } else if (A === 2) {
      if(tmp[0] < maxX){
        maxX = tmp[0];
      }
    } else if (A === 3) {
      if(tmp[1] > minY) {
        minY = tmp[1];
      }
    } else if (A === 4) {
      if(tmp[1] < maxY) {
        maxY = tmp[1];
      }
    }
  }

  const X = maxX - minX;
  const Y = maxY - minY;
  if(X <= 0 || Y <= 0){
    console.log(0);
  } else {
    console.log(X*Y);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), ans = 0;
    for (int i=0; i<n; i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
    int N,input,alice=0,bob=0;
    cin >> N;
    vector<int> data(N);

    for(int i=0;i<N;i++){
      cin >>input;
      data.push_back(input);

    }
    sort(data.begin(), data.end());
    reverse(data.begin(), data.end());

    for(int i=0;i<N;i++){
        alice += data.at(i);
        i++;
        bob += data.at(i);
    }

    cout<<alice - bob<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s[10]={
	"* = ****",
	"* =* ***",
	"* =** **",
	"* =*** *",
	"* =**** ",
	" *= ****",
	" *=* ***",
	" *=** **",
	" *=*** *",
	" *=**** "
};
int main(){
	string d;
	int c[5];
	bool first=true;
	while(cin>>d){
		if(!first)cout<<endl;
		first=false;
		for(int i=0;i<5;i++)c[i]=0;
		for(int i=0;i<d.size();i++)c[5-d.size()+i]=d[i]-'0';
		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				cout<<s[c[j]][i];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int n, mx = 0, counter = 0;
int ab[100000][2] = {};
map<int, vector<int>> mp;
map<P, int> res;

void dfs(int prev, int now){
    if(counter == n) return;

    int color_num = 1;
    for(int i=0; i<mp[now].size(); i++){
        if(mp[now][i] == prev) continue;
        if(color_num == res[P(prev, now)]){
            color_num++;
        }
        if(res[P(now, mp[now][i])] == 0 && res[P(mp[now][i], now)] == 0){
            res[P(now, mp[now][i])] = color_num;
            counter++;
            dfs(now, mp[now][i]);
            color_num++;
        }
    }
    mx = max(color_num-1, mx);
}

int main(){
    int a, b, i;
    cin >> n;
    for(i=0; i<n-1; i++){
        cin >> a >> b;
        ab[i-1][0] = a-1;
        ab[i-1][1] = b-1;
        mp[a-1].push_back(b-1);
        mp[b-1].push_back(a-1);
    }
    dfs(-1, 0);
    printf("%d\n", mx);
    for(i=0; i<n-1; i++){
        int output = (res[P(ab[i-1][0], ab[i-1][1])] ? res[P(ab[i-1][0], ab[i-1][1])] : res[P(ab[i-1][1], ab[i-1][0])]);
        printf("%d\n", output);
    }
}

Measured memory_bytes: 24704
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	string t,s;cin>>t>>s;
  	cout<<s<<t;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  while(0 < a,b,c < 100){
	if (a < b && b < c) {
    printf("Yes\n");
    break;
	} else {
	  printf("No\n");
	  break;
	}
	
  }

  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	int mxN = 1e5 + 2;
	
	int ar[mxN];
	
	int dp[mxN];
	
	for(int i = 0; i<n; i++){
		int x;
		cin>>x;
		ar[i] = x;
	}
	
	dp[0] = 0;
	dp[1] = abs(ar[0] - ar[1]);
	
	for(int i = 2 ; i<n; i++){
		dp[i] = min(dp[i-1] + abs(ar[i] -ar[i-1]),dp[i-2] + abs(ar[i] -ar[i-2]));
	}
	cout<<dp[n-1];
}
		


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

using namespace std;

int n,y;

int main()
{
//	freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	cin>>n>>y;
	int i,j;
	for (i=0;i<=n;i++){
		for (j=0;j<=n-i;j++){
			int k=n-i-j;
			if (i*10000+j*5000+k*1000==y){
				cout<<i<<' '<<j<<' '<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0L;
            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    if (i == j) continue;
                    ans += d[i] * d[j];
                }
            }

            Console.WriteLine(ans / 2);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e6+10;
char t[maxn],s[maxn];
int main()
{
    long long x,y;
    cin>>x>>y;
    cout<<x*y/__gcd(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    k, s = map(int, input().split())
    answer = 0
    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if 0 <= z <= k:
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int n = sc.nextInt();
		long min = 0;
		long max = 0;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			int num = Integer.parseInt(sc.next());
			if (num <= min || i == 0) {
				min = num;
			}
			if (max <= num || i == 0) {
				max = num;
			}
			sum += num;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    vector<int> acc(n+1, 0);
    for (int i = 0; i < n; i++) acc[i+1] = acc[i] + t[i];
    vector<vector<float>> lmt(n+2, vector<float>(acc.back()*2 + 1));
    for (int i = 0; i < acc.back()*2 + 1; i++){
        lmt[0][i] = 1.0f * i / 2;
        lmt[n+1][i] = 1.0f * (acc.back()*2 - i) / 2;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < acc.back()*2 + 1; j++){
            if (1.0f * j / 2 < acc[i-1]) lmt[i][j] = v[i-1] + (acc[i-1] - 1.0f * j / 2);
            else if (1.0f * j / 2 > acc[i]) lmt[i][j] = v[i-1] + (1.0f * j / 2 - acc[i]);
            else lmt[i][j] = v[i-1];
        }
    }

    float ans = 0;
    for (int i = 0; i < acc.back()*2 + 1; i++){
        float min_v = 200;
        for (int j = 0; j < n+2; j++) min_v = min(min_v, lmt[j][i]);
        ans += min_v * 2;
    }
    cout << setprecision(10) << ans / 4 << endl;
}

Measured memory_bytes: 16768
S = int(input())
a = S % 100
b = (S- (S % 100))/100
if   b <= 12 and  a<=12 and a!=0 and b!= 0:
       print("AMBIGUOUS")
elif b <= 12 and b!=0:
       print("MMYY")
elif a<=12 and a!=0  :
       print("YYMM")
else :
      print("NA")

Measured memory_bytes: 8964
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 998244353;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  ll sum = 0;
  cin>>n;
  unordered_map<int, int>mp;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    mp[x]++;
    sum+=x;
  }
  int q;
  cin>>q;
  while(q--){
    int b,c;
    cin>>b>>c;
    if(mp[b]==0){
      cout<<sum<<endl;
      continue;
    }
    int tt = mp[b];
    mp[b] = 0;
    sum -= tt * (ll)b;
    mp[c] += tt;
    sum += c * (ll)tt;
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 6932