akhauriyash/Code-Regression huggingface dataset:
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()


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

using namespace std;
const int MAXN = 500;
string s;

int check(string s, char c) {
    string r = "";
    int n = s.length();

    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (s[i] != s[0]) ok = false;
    }

    if (ok) return 0;

    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == c)
            r.push_back(c);
        else
            r.push_back(s[i+1]);
    }

    return 1 + check(r, c);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> s;

    int mi = 123;
    for (int i = 'a'; i <= 'z'; i++)
        mi = min(mi, check(s, i));
    cout << mi << "\n";
    return 0;
}


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

int main(){
  int n,d[105];
  cin >>n;
  rep(i,n) cin >>d[i];
  int num[105] = {0};
  rep(i,n) num[d[i]]++;
  int cnt = 0;
  rep(i,105){
    if(num[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int x;
	int a;

	cin >> x;
	cin >> a;
	
	int return_value = 0;

	if (x < a) {
		return_value = 0;
	} else {
		return_value = 10;
	}
	
	cout << return_value << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

class Main {

    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static  void solve() throws IOException {
        //	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        int n=sc.I();
        int a[]=new int[n+1];
        long ans=(long)Math.pow(3,n);
        long d=1;
        for(int i=1;i<=n;i++){
            a[i]=sc.I();
            int c=0;
            if(a[i]%2!=0) c++;
            if((a[i]+1)%2!=0) c++;
            if((a[i]-1)%2!=0) c++;
            d=d*c;
        }
        pw.println(ans-d);
        pw.close();

    }


    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            br = new BufferedReader(new InputStreamReader(System.in));

        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int I() {
            return Integer.parseInt(next());
        }

        long L() {
            return Long.parseLong(next());
        }

        double D() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}

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

int main()
{
    int k;
    cin>>k;
    ll sum=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int p=1;p<=k;p++)
            {
                int a = __gcd(i,j);
                sum+=__gcd(a,p);
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3548
N,L = map(int,input().split())
a = list(map(int,input().split()))
x = N
for i in range(1,N):
    if a[i] + a[i-1] >= L:
        x = i
if x == N:
    print('Impossible')
    exit()
print('Possible')
for i in range(1,x):
    print(i)
for i in range(N-1,x-1,-1):
    print(i)


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  int c;
  
  cin >> a >> b;
  
  if(a%2==0||b%2==0)
  {
  	cout << "Even" << endl;
  }
  else{
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define el "\n" ;
ll v[100005][3] ;
ll dp[100005][3] ;
int main(){
    ll n ; cin >> n ;
    for(ll i = 0 ; i < n ; i++){
        for(ll j =0 ; j < 3 ; j++){
            cin >> v[i][j] ;
        }
    }
    for( ll i = 0 ; i < 3 ; i++){
        dp[0][i] = v[0][i] ;
    }
    for( ll i = 1 ; i < n ; i++){
        for( ll j = 0 ; j < 3 ; j++){
            for(ll k  = 0 ; k < 3 ; k++ ){
                if( k == j) continue ;
                dp[i][j] = max(dp[i][j] , dp[i-1][k] + v[i][j] ) ;
            }
        }
    }
    ll maxi = INT32_MIN ;
    for( ll i = 0 ; i < 3 ; i++){
        maxi = max( maxi , dp[n-1][i]) ;
    }
    cout << maxi << el ;
    return 0 ;
}

Measured memory_bytes: 8216
#include <cstdio>
int n,ans;
char ch1,ch2;
int main()
{
	scanf("%d",&n);
	ch1=getchar();
	ch1=getchar();
	ans=1;
	for(int i=1;i<n;i++)
	{
	    ch2=getchar();
	    if(ch2!=ch1) ans++;
	    ch1=ch2;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
// D - AtCoder Express 2
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N,M,Q; cin>>N>>M>>Q;
	vvi X(N+1, vi(N+1, 0));
	rep(i, M){ int l,r; cin>>l>>r; X[l][r]++; }
	rep(l, N) rep(r, N) X[l+1][r+1] += X[l+1][r];
	rep(r, N) rep(l, N) X[l+1][r+1] += X[l][r+1];
	while(Q--){
		int p,q; cin>>p>>q;
		cout<< X[N][q] - X[p-1][q] <<endl;
	}
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int count = 0;
  while(1){
      string b;
      cin >> b;
      if(b == "END_OF_TEXT")break;
    transform(b.begin(), b.end(), b.begin(), ::tolower);
    if(b == a)count++;
  }
  cout << count << endl;
}


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

int main () {
	long N;
	cin >> N;
	long *a = new long[N];
	long *b = new long[N];
	int tempa;
	for (int i=0; i<N; ++i) {
		cin >> tempa;
		a[i] = tempa;
	}

	long sum;
	long count;
	for (long i=N-1; i>=0; --i) {
		sum = 0;
		for (long j=i; j<N; j += (i+1)) {
			sum += b[j];
		}
		if (sum%2 == a[i]) {
			b[i] = 0;
		} else {
			b[i] = 1;
			++count;
		}
	}

	cout << count << endl;
	for (long i=0; i<N; i++) {
		if (b[i] == 1) cout << i+1 << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3968
#include<stdio.h>
#define ll long long
double p[400][400][400],e[400][400][400],po,pw,ew;
int main()
{
     ll n;
     scanf("%lld",&n);
     ll cnt[4]={0},cnt3=0,x;
     for(int i=0;i<n;i++)
     {
          scanf("%lld",&x);
          cnt[x]++;
     }
     for(int i=0;i<=n;i++)
          for(int j=0;j<=n;j++)
               for(int k=0;k<=n;k++)
               {
                    e[i][j][k]=0;
                    p[i][j][k]=0;
               }
     p[cnt[1]][cnt[2]][cnt[3]]=1;
     for(ll c=n;c>=0;c--)
          for(ll b=n;b>=0;b--)
               for(ll a=n;a>=0;a--)
               {
                    if(a==0&&b==0&&c==0)
                    continue;
                    if(a+b+c>n)
                    continue;
                    pw=(double)(n-(a+b+c))/n;
                    ew=pw/(1-pw)+1;
                    e[a][b][c]+=ew*p[a][b][c];
                    if(a!=0)
                    {
                         po=(double)a/(a+b+c);
                         p[a-1][b][c]+=p[a][b][c]*po;
                         e[a-1][b][c]+=e[a][b][c]*po;
                    }
                    if(b!=0)
                    {
                         po=(double)b/(a+b+c);
                         p[a+1][b-1][c]+=p[a][b][c]*po;
                         e[a+1][b-1][c]+=e[a][b][c]*po;
                    }
                    if(c!=0)
                    {
                         po=(double)c/(a+b+c);
                         p[a][b+1][c-1]+=p[a][b][c]*po;
                         e[a][b+1][c-1]+=e[a][b][c]*po;
                    }

               }
     printf("%.10lf\n",e[0][0][0]);
     return 0;
}

Measured memory_bytes: 753536
#include <stdio.h>

int main(void)
{
	int i,j,n,side[3];

	scanf("%d",&n);
	while(n) {
		scanf("%d %d %d",&side[0],&side[1],&side[2]);
		for(i=0;i<3;i++) {
			for(j=i+1;j<3;j++) {
				if(side[i]<side[j]) {
					int tmp=side[i];
					side[i]=side[j];
					side[j]=tmp;
				}
			}
		}
		if(side[0]*4==side[1]*5&&side[0]*3==side[2]*5) {
			printf("YES\n");
		}else {
			printf("NO\n");
		}
		n--;
	}
	return 0;
}

Measured memory_bytes: 580
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use proconio::marker::Usize1;
// use std::cmp::max;
// use std::cmp::min;
// use std::collections::HashMap;
// use std::collections::VecDeque;

// 自力で解こうとしたがうまくいかなかったので答えを見た
// 2次元累積和を使うO(Q + N^2)解法

fn main() {
    input! {
        N: usize,
        M: usize,
        Q: usize,
        LRs: [(Usize1, Usize1); M],
        PQs: [(Usize1, Usize1); Q],
    }

    // O(10^5)のループの内側でクエリに回答する
    // つまり、クエリへの回答はO(1)でできる必要がある (← 注: これ嘘です。10^7までは食えるので今回はO(NQ)までいけます)
    // ある「領域」に属する個数の総和を高速で求める → 累積和
    // ここで、領域は幅を持っている → 2次元累積和

    // imos[l][r] : 「[0, l),[0, r) の区間に含まれる電車の数」
    let mut acc: Vec<Vec<i64>> = vec![vec![0i64; N + 1]; N + 1];

    for &(l, r) in LRs.iter() {
        acc[l + 1][r + 1] += 1;
    }

    // 横方向の和
    for l in 0..N + 1 {
        for r in 1..N + 1 {
            acc[l][r] += acc[l][r - 1];
        }
    }

    // 縦方向の和
    for r in 0..N + 1 {
        for l in 1..N + 1 {
            acc[l][r] += acc[l - 1][r];
        }
    }

    for &(p, q) in PQs.iter() {
        // ループの中はほぼO(1)じゃないと間に合わない (← 注: これ嘘です。10^7までは食えるので今回はO(NQ)までいけます)
        // 区間、O(1)と来れば累積和でしょう

        let ans = acc[q + 1][q + 1] - acc[q + 1][p] - acc[p][q + 1] + acc[p][p];
        println!("{}", ans);
    }
}


Measured memory_bytes: 10980
N = int(input())

flg = False

a = int(N/4)
b =int(N/7)

for i in range(a+1):
    for j in range(b+1):
        if i*4+j*7 == N:
            flg = True 
            break
            
    if flg == True:
        break
            
            
                    
if flg == True:
    print('Yes')
else:
    print('No')
        
            

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>

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

long long a[100010][3];
long long dp[100010][3];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}

	long long res = 0;
	for (int i = 0; i < 3; i++) chmax(res, dp[N][i]);
	cout << res << endl;

	return 0;
}


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

int main(void){
	double tmp,cmax,cmin;
	cin >> tmp;
	cmax=cmin=tmp;
	while(cin >> tmp){
		if(cin.eof())
			break;
		cmax=max(cmax,tmp);
		cmin=min(cmin,tmp);
	}
	cout  << cmax-cmin << endl;
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split();
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        if ((a + b) % 2 == 0)
        {
            Console.WriteLine((a + b) / 2);
        }
        else
        {
            Console.WriteLine("IMPOSSIBLE");
        }
    }
}


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

typedef long long ll;

/*
  let's try computer shogi!!!
 */


int main(){
  int r,g,b,n;
  cin >> r>>g>>b>>n;
  ll dp[3001];
  ll dp_copy[3001];
  for(int i=0;i<n+1;++i){
    dp[i] = 0;
  }
  
  for(int i=0;i<n/r+1;++i){
    dp[i*r] = 1;
  }

  for(int i=0;i<n+1;++i){
    cerr<<dp[i]<<",";
    dp_copy[i] = dp[i];
    dp[i] = 0;
  }
  cerr<<endl;
  for(int i=0;i<n/g+1;++i){
    for(int j=0;j<3001;++j){
      if(j+i*g>3000){
	continue;
      }
      dp[j+i*g] += dp_copy[j];
    } 
  }
  for(int i=0;i<n+1;++i){
    cerr<<dp[i]<<",";
    dp_copy[i] = dp[i];
    dp[i] = 0;
  }
  cerr<<endl;
  
  
  for(int i=0;i<n/b+1;++i){
    for(int j=0;j<3001;++j){
      if(j+i*b>3000){
	continue;
      }
      dp[j+i*b] += dp_copy[j];
    } 
  }

  for(int i=0;i<n+1;++i){
    cerr<<dp[i]<<",";
    dp_copy[i] = dp[i];
  }
  cerr<<endl;

  cout<<dp[n]<<endl;
  return 0;
}

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= b && b <= c)
	{
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= c && c <= b)
	{
		cout << a << " " << c << " " << b << endl;
	}
	else if (c <= b && b <= a)
	{
		cout << c << " " << b << " " << a << endl;
	}
	else if (c <= a && a <= b)
	{
		cout << c << " " << a << " " << b << endl;
	}
	else if (b <= a && a <= c)
	{
		cout << b << " " << a << " " << c << endl;
	}
	else if (b <= c && c <= a)
	{
		cout << b << " " << c << " " << a << endl;
	}
	else
	{
		cout << "error";
	}

	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int i,N = S.size(),c=0;

    for(i=0; i<N/2; i++)
        if(S.at(i) != S.at(N-1-i))
            c++;
    cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
int main(){
    ll n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        ll hoge;
        cin>>hoge;
        ans+=hoge-1;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

int N;

long long int a[20][20];

long long int dp[1 << 17];
long long int dp2[1 << 17];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cin >> a[i][j];
		}
	}

	//=========== dp2 =====//

	for (int k = 0; k < (1 << N) - 1; k++) {

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

			long long int tmp = 0;
			if((k&(1<<(m-1)))==0){ 
				for (int n = 1; n <= N; n++) {
					if ((k&(1 << (n - 1))) != 0) { tmp += a[m][n]; }
			   }

			}

			dp2[k | (1 << (m - 1))] = dp2[k] + tmp;
		}
	}

	/*for (int i = 0; i <= (1<<N)-1; i++) {
		cout << "dp2[" << bitset<8> (i) << "]= " << dp2[i] << endl;

	}*/


	//======================//
	dp[1 << N - 1] = 0;

	for (int k = (1 << N) - 1; k >= 1; k--) {

		for (int t = k; t != 0; t = (t - 1)&k) {
			dp[k&(~t)] = max(dp[k&(~t)], dp[k] + dp2[t]);
		}
	}

	cout << dp[0] << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n, m;
	cin >> n >> m;
	vector<ll> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	vector<vector<int>> a(n, vector<int>());
	for (int i = 0; i < m; i++)
	{
		int c, b;
		cin >> c >> b;
		c--;
		b--;
		a[c].push_back(b);
		a[b].push_back(c);
	}

	int r = 0;

	for (int i = 0; i < n; i++)
	{
		bool g = true;
		for (auto j : a[i])
			if (h[j] >= h[i])
			{
				g = false;
				break;
			}
		if (g)
			r++;
	}

	printf("%d", r);
	return 0;
}

Measured memory_bytes: 8692
N = int(input())
H = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(1,N):
    if H[i]<=H[i-1]:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=5e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    if (s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << max({ a * c, a * d, b * c, b * d });

	return 0;
}

Measured memory_bytes: 3648
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [a,b] <- getl $ split toDbl
  print $ solve a b

solve :: Double -> Double -> Double
solve a b = (a * b) / 3.305785

toDbl :: String -> Double
toDbl s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 3844
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int s;
    cin >> s;
    int a[100001]={0};
    int i=1;
    while(!a[s]){
        a[s]=1;
        if(s%2){
            s=s*3+1;
        }else{
            s=s/2;
        }
        i++;
    }
    cout << i << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int N;

	scanf("%d",&N);

	switch(N){
	case 0:
	case 2: printf("1\n");
			break;
	case 1:
			printf("2\n");
			break;
	default:
			printf("0\n");
			break;
	}

	return 0;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  string s, t;
  cin >> N >> s >> t;
  FOR(i, N) { cout << s[i] << t[i]; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s1 = str(input())
s2 = str(input())
MOD = 10 ** 9 + 7
S1, S2 = s1[0], s2[0]
for i in range(1, n):
    if S1[-1] != s1[i]:
        S1 += s1[i]
        S2 += s2[i]
if S1[0] == S2[0]:
    ans = 3
    cnd = 0
else:
    ans = 6
    cnd = 1
for i in range(1, len(S1)):
    if cnd == 0:
        if S1[i] == S2[i]:
            ans *= 2 % MOD
        else:
            ans *= 2 % MOD
            cnd = 1
    else:
        if S1[i] == S2[i]:
            cnd = 0
        else:
            ans *= 3 % MOD
print(ans % MOD)


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 10
#define MAX_M 10
#define ALL_PATTERN 1024

i64 N, M;
i64 swt[MAX_N];
i64 bulb[MAX_M];
i64 P[MAX_M];
i64 pattern[ALL_PATTERN][MAX_N];
i64 n_on[ALL_PATTERN][MAX_M];

int main() {
  cin >> N >> M;

  i64 n_pattern = pow(2, N);
  i64 m = n_pattern;
  REP(j, N) {
    m = m / 2;
    REP(i, n_pattern) {
      pattern[i][j] = (i / m) % 2;
    }
  }

  REP(i, n_pattern) {
    REP(j, M) {
      n_on[i][j] = 0;
    }
  }

  i64 k, s;
  REP(i, M) {
    cin >> k;

    REP(_, k) {
      cin >> s;
      REP(j, n_pattern) {
        n_on[j][i] += pattern[j][s-1];
      }
    }
  }

  i64 cnt = 0;
  bool all_on;
  REP(i, M) {
    cin >> P[i];
  }
  REP(j, n_pattern) {
    all_on = true;
    REP(i, M) {
      if (n_on[j][i] % 2 != P[i]) {
        all_on = false;
        break;
      }
    }
    if (all_on) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int, input().split())
R,S,P=map(int, input().split())
T=input()
hand=[0]*(len(T))
for i in range(len(T)):
    if (i>K-1) and (T[i]==T[i-K]) and (hand[i-K]!=0):
            hand[i]=0
    elif (T[i]=='r'):
        hand[i]=P
    elif (T[i]=='s'):
        hand[i]=R
    elif (T[i]=='p'):
        hand[i]=S
print(sum(hand))

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string y = "Yes";
string n = "No";

int  main()
{
	int x, y; cin >> x >> y;

	bool ans = false;
	for (int i = 0; i <= x; i++)
	{
		for (int j = 0; j <= x; j++)
		{
			if (i+j == x && (i*2) + (j*4) == y)
				ans = true;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return (0);
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n]; 
    // 駄目なら1
    int[] dame = new int[n];
    for(int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
      if((i + 1) == p[i]) dame[i] = 1;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
      if(dame[i] == 1) {
        if(i < n - 1) {
          if(dame[i + 1] == 1) {
            ans++;
            dame[i + 1] = 0;
          } else {
            ans++;
          }
        } else {
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 63316
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
typedef long long ll;

using namespace std;
int main()
{
	int n,k;
	cin >> n>>k;
	vector<int> box(200001,0);
	for (int i = 0; i < n; i++) {
		int dammy;
		cin >> dammy;
		box[dammy] += 1;
	}
	sort(box.begin(), box.end(), greater<int>());

	int kotae = 0;
	for (int i = k; i < box.size(); i++) {
		kotae += box[i];
	}
	cout << kotae;
	return 0;
}

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

using namespace std;

int main(){
        int N, M;
        vector <int> t;
        vector <int> p, x;
        cin>>N;
        int tsum=0;
        for(int i=0;i<N;i++){
                int tt;
                cin>>tt;
                t.push_back(tt);
                tsum+=tt;
        }
        cin>>M;
        for(int i=0;i<M;i++){
                int pp, xx;
                cin>>pp>>xx;
                p.push_back(pp);
                x.push_back(xx);
        }
        for(int i=0;i<M;i++){
                int res=t[p[i]-1]-x[i];
                cout<<tsum-res<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
S = input()

max_len = 0
tmp = 0
for s in S:
    if s in "ACGT":
        tmp = tmp + 1
    elif max_len < tmp:
        max_len = tmp
        tmp = 0
    else:
        tmp = 0
if max_len < tmp:
    max_len = tmp

print(max_len)


Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		Integer N[] = new Integer[4];
		for(int i = 0; i < 4; i++) {
			N[i] = sc.nextInt();
		}
		
		if(Arrays.asList(N).contains(1) && Arrays.asList(N).contains(7) && Arrays.asList(N).contains(9) && Arrays.asList(N).contains(4)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d; cin >> a >> b >> c >> d;
	a--;
	int tmp = b;
	tmp -= b / c;
	tmp -= b / d;
	tmp += b / (lcm(c, d));
	int tmp2 = a;
	tmp2 -= a / c; tmp2 -= a / d;
	tmp2 += a / (lcm(c, d));
	cout << tmp - tmp2 << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[0 for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    l[i]=a,b,a+b
l=sorted(l,key=lambda x:-x[2])
ans=0
for num,i in enumerate(l):
    if num%2==0:ans+=i[0]
    else:ans-=i[1]
print(ans)

Measured memory_bytes: 26108
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	char buf[101],result[1100],ch;
	int p,limit;

	while(scanf("%s",buf)!=EOF){
		p = 0;
		for(int i=0; buf[i] != '\0';){
			if(buf[i] == '@'){
				ch = buf[i+2];
				limit = buf[i+1] - '0';
				for(int k = 0; k < limit; k++){
					result[p++] = ch;
				}
				i += 3;
			}else{
				result[p++] = buf[i];
				i++;
			}
		}
		result[p] = '\0';
		printf("%s\n",result);
	}

	return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<int> c(n);
  ll ret = 1;
  vector<int> last(3, 0);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (last[j] == c[i]) cnt++;
    }
    ret = ret * cnt % MOD;
    for (int j = 0; j < 3; j++) {
      if (last[j] == c[i]) {
        last[j]++;
        break;
      }
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 640
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, k; cin >> n >> k;
    vector<int> l(n);
    rep(i, n) {
        cin >> l[i];
    }
    sort(all(l));
    reverse(all(l));
    int ans = 0;
    rep(i, k) {
        ans += l[i];
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
  int x,y;cin>>x>>y;
  if(x%y==0)cout<<-1<<endl;
  else cout<<x<<endl;
}

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

float det(float a[2][2]){
	return a[0][0]*a[1][1]-a[0][1]*a[1][0];
}
float detx(float a[2][2],float p,float q){
	return p*a[1][1]-a[0][1]*q;
}
float dety(float a[2][2],float p,float q){
	return a[0][0]*q-p*a[1][0];
}

int main(){
	float a[2][2];
	float p,q;

	while(cin>>a[0][0]>>a[0][1]>>p>>a[1][0]>>a[1][1]>>q){
		float d1;
		float x,y;
		d1=det(a);
		x=detx(a,p,q)/d1;
		if(x==-0) x=0;
		y=dety(a,p,q)/d1;
		if(y==-0) y=0;
		cout.precision(3);
		cout.setf(ios::fixed);
		cout<<x<<" "<<y<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1284
N=int(input())
L=input().split()
for i in range(N): L[i]=int(L[i])
L.sort()
res=0
if N<3: print(0)
else:
  for i in range(N):
    for j in range(i+1,N):
      if L[j]==L[i]: continue
      for k in range(j+1,N):
        if L[i]==L[k] or L[j]==L[k]: continue
        if L[k]<L[j]+L[i]: res+=1
  print(res)

Measured memory_bytes: 9204
#include<stdio.h>
#include<math.h>
 
int main(){
    int k;
    double x1,x2,x3,x4,y1,y2,y3,y4;
    scanf("%d",&k);
    while(k--){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if(fabs((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1))<1e-10) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int tab [301][301];
int a[301][301];
int main() {
    int n;
    cin >> n;
    long long sum(0);
    for(int i = 1 ; i <= n ; i++)
    for(int j = 1 ; j <= n ; j++){
        cin >> tab[i][j];
    }
    for(int i = 1 ; i <= n ; i++)
    for(int j = 1 ; j <= n ; j++){
        for(int k = 1 ; k <= n ; k++){
            if(tab[i][j] > tab[i][k] + tab[j][k]){
                cout << -1;
                return 0;
            }
            if(tab[i][j] == tab[i][k] + tab[j][k] && k != i && k != j){
                    a[i][j] = 1;
            }
        }
    }
    for(int i = 1 ; i <= n ; i++)
    for(int j = 1 ; j <= n ; j++)
        if(a[i][j] == 0 ){
            sum += tab[i][j];
        }

    cout << sum/2;

    return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int taka = ceil((double)a / d);
    int ao = ceil((double)c / b);

    if(taka >= ao) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3588
n = int(input())
A = list(map(int, input().split()))

max_a = max(A)
min_a = min(A)

max_a_ind = A.index(max_a)
min_a_ind = A.index(min_a)

if min_a >= 0:
    check = 'sei'
elif max_a > 0 and min_a < 0:
    check = 'seifu'
else:
    check = 'fu'

if check == 'sei':
    print(n-1)
    for i in range(n-1):
        print(str(i+1) + ' ' + str(i+2))
elif check == 'fu':
    print(n-1)
    for i in range(n-2, -1, -1):
        print(str(i+2) + ' ' + str(i+1))
else:
    if abs(max_a) >= abs(min_a):
        print(n+n-1)
        for i in range(n):
            print(str(max_a_ind+1) + ' ' + str(i+1))
        for i in range(n-1):
            print(str(i+1) + ' ' + str(i+2))
    else:
        print(n+n-1)
        for i in range(n):
            print(str(min_a_ind+1) + ' ' + str(i+1))
        for i in range(n-2, -1, -1):
            print(str(i+2) + ' ' + str(i+1))

Measured memory_bytes: 3064
n, m = map(int, input().split())
mod = 1000000007

def cmb(n, k):
    ret = 1
    for i in range(k):
        ret *=  n - i
        ret //= i + 1
    return ret % mod

primes = [2]
for p in range(3, 1000):
    if all(p % q for q in primes):
        primes.append(p)

ret = 1
for p in primes:
    q = 0
    while m % p == 0:
        m //= p
        q += 1
    if q > 0:
        ret = (ret * cmb(n + q - 1, q)) % mod
if m > 1:
    ret = (ret * cmb(n, 1)) % mod

print(ret)


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

int main(){
  string A,B;
  cin >> A;
  cin >> B;
  string s="EQUAL";
  if(A.size()>B.size()){
     s = "GREATER";
  }
  else if(A.size()<B.size()){
     s = "LESS";
  }
  else{
    for(int i=0;i<A.size();i++){
      if(A.at(i)>B.at(i)){
        s = "GREATER";
        break;
      }
      else if(A.at(i)<B.at(i)){
        s = "LESS";
        break;
      }
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int mdays[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const char* days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main(void) {
    int a, b, d;
    while (true) {
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        d = 3;
        for (int m = 0; m < a - 1; m++) d += mdays[m];
        d += b - 1;
        cout << days[d % 7] << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
n = int(input())
h=list(map(int,input().split()))
def jud(n,h):
    for i in list(reversed(range(0,n-1))):
        # print(h[i],h[i+1])
        if h[i+1]-h[i]==-1:
            h[i]-=1
            # print(h[i])
            continue
        if h[i]-h[i+1]>1:
            return "No"
            break
    return "Yes"

print(jud(n,h))


Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> num_divisors(N + 1);
  for (int i = 1; i <= N; ++i) {
    for (int j = i; j <= N; j += i) {
      ++num_divisors[j];
    }
  }
  std::int64_t sum = 0;
  for (std::int64_t K = 1; K <= N; ++K) {
    sum += K * num_divisors[K];
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 42328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, k, v[200100];

ll need(ll len) {
	ll total = 0;
	for (int i = 1; i <= n; i++)
		total += (v[i] + len - 1) / len - 1;
	return total;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> v[i];

	ll st = 1, dr = 1000000000;
	while (st < dr) {
		ll mij = (st + dr) / 2;
		if (need(mij) <= k)
			dr = mij;
		else
			st = mij + 1;
	}
	if (need(st) > k)
		st--;
	cout << st;
    return 0;
}


Measured memory_bytes: 5172
require 'prime'

dp = 14.times.map{ [0] * 1121 }
cnt = 0
Prime.each.take_while{ |p| p < 1120 }.each do |p|
  cnt.downto(1) do |i|
    (2..1120 - p).each do |k|
      dp[i][k + p] += dp[i - 1][k]
    end
  end
  dp[0][p] = 1
  cnt += 1 if cnt < 13
end

loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  puts dp[k - 1][n]
end

Measured memory_bytes: 9016
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
    int n, ans = 1;
    cin >> n;
    vector<int> h(n);
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    
    for(int i = 1;i < n;i++){
        for(int j = 0;j < i;j++){
            if(h[j] > h[i]){
                ans--;
                break;
            }
        }
        ans++;
    }

    cout << ans << "\n";

    return 0;
}

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

void    comb(vector<vector<long long int>> &v){
        for (int i=0; i<v.size(); i++){
                v.at(i).at(0)=1;
                v.at(i).at(i)=1;
        }
        for (int k=1; k<v.size(); k++){
                for (int j=1; j<k; j++){
                        v.at(k).at(j)=((v.at(k-1).at(j-1)+v.at(k-1).at(j))) % 1000000007;
                }
        }
}

int     main() {
        int N, K;
        cin >> N >> K;
        int NN=max(N-K, K);
        NN++;
        vector<vector<long long int>> v(NN+1, vector<long long int>(NN+1, 0));
        comb(v);
        long SS=0;
//      SS+=v.at(N-K).at(1)*2 + v.at(N-K).at(2);
//      cout <<SS <<endl;
        for (int i=1; i<=K; i++){
                SS=0;
//              SS+=v.at(N-K).at(i-1) + v.at(N-K).at(i)*2 + v.at(N-K).at(i+1);
                SS+=v.at(N-K+1).at(i);
                SS %= 1000000007;
                SS *= v.at(K-1).at(i-1);
                SS %= 1000000007;
                cout <<SS <<endl;
        }
        return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int N;
    cin>>N;
    if(N%2==0) cout<<N/2-1<<endl;
    else cout<<N/2<<endl;
    return 0;
}


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

using namespace std;

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

        int q;
        cin >> q;

        int t, f;
        char c;
        int rev_cnt = 0;
        for (int i = 0; i < q; i++) {
            cin >> t;
            if (t == 1) {
                rev_cnt++;
            }
            else {
                cin >> f >> c;
                if ((f+rev_cnt)%2) {
                    s.insert(s.begin(),c);
                }
                else {
                    s += c;
                }
            }
    }
        if (rev_cnt % 2)reverse(s.begin(), s.end());
        cout << s << endl;
    
}


Measured memory_bytes: 900
def main():
    [a, b, c, k] =[int(x) for x in input().split()]
    overflowk = 10 ** 18
    ansk = a - b
    if abs(ansk) > overflowk:
        print("Unfair")
    else:
        if (k % 2 != 0):
            ansk = -ansk
        print(ansk)
if __name__ == "__main__":
    main()


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

int main() {
  int N, A;
  int count, ans=1e9;
  
  cin >> N;

  for (int i=0; i<N; i++) {
    cin >> A;
    count = 0;
    
    while ( true ) {
      if ( (A % 2)==0 ) {
        count++;
        A /= 2;
      }
      else break;
    }
    
    if ( ans > count ) ans = count;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::collections::HashSet;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let hw = read_vec::<usize>();
    let h = hw[0];
    let w = hw[1];

    let mut shogai_yoko : Vec<Vec<usize>> = Vec::with_capacity(h);
    let mut shogai_tate : Vec<Vec<usize>> = Vec::with_capacity(w);
    for _i in 0..w {
        let v : Vec<usize> = Vec::with_capacity(h);
        shogai_tate.push(v)
    }
    
    for i in 0..h {
        let mut v : Vec<usize> = Vec::with_capacity(w);
        let s = read::<String>();
        for (j, c) in s.chars().enumerate() {
            if c == '#' {
                v.push(j);
                shogai_tate[j].push(i)
            }
        }
        if v.is_empty() || v[v.len()-1] < w - 1 {
            v.push(w);
        }
        shogai_yoko.push(v);
    }
    for j in 0..w {
        let v = &mut shogai_tate[j];
        if v.is_empty() || v[v.len() - 1] < h - 1 {
            v.push(h)
        }
    }


    let answer = solve(h, w, &shogai_yoko, &shogai_tate);
    println!("{}", answer);
}

fn solve(h: usize, w: usize, shogai_yoko: &[Vec<usize>], shogai_tate: &[Vec<usize>]) -> usize {
     // (yoko, tate)
     let mut dp : Vec<Vec<usize>> = Vec::with_capacity(h);
     for _i in 0..h {
        let v : Vec<usize> = vec![0; w];
        dp.push(v);
     }

     // yoko
     for i in 0..h {
        let mut from = 0;
        for x in &shogai_yoko[i] {
            let d = x - from;
            if d > 1 {
                for j in from..*x {
                    dp[i][j] = d - 1;
                }
            }
            from = x + 1;
        }
    }

    // tate (and total)
    let mut max = 0;
    for j in 0..w {
        let mut from = 0;
        for x in &shogai_tate[j] {
            let d = x - from;
            if d > 0 {
                for i in from..*x {
                    let val = dp[i][j] + (d - 1);
                    if val > max {
                        max = val
                    }
                }
            }
            from = x + 1;
        }
    }
    return max + 1
}

Measured memory_bytes: 127228