akhauriyash/Code-Regression huggingface dataset:
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N, W;
double V;
int w[MAX_N], v[MAX_N];
vector<pair<double, int> > r;

int main() {
  cin >> N >> W;
  rep(i, N) {
    cin >> w[i] >> v[i];
    if (w[i] >= 0 && v[i] <= 0) {
      continue;
    } else if (w[i] <= 0 && v[i] >= 0) {
      W -= w[i];
      V += v[i];
    } else {
      if (w[i] < 0 && v[i] < 0) {
        W -= w[i];
        V += v[i];
        w[i] = -w[i];
        v[i] = -v[i];
        r.push_back(pair<double, int>((double)v[i]/(double)w[i], i));
      } else {
        r.push_back(pair<double, int>((double)v[i]/(double)w[i], i));
      }
    }
  }
  
  sort(all(r), greater<pair<double, int> >());

  for (int i = 0; i < (int)r.size(); ++i) {
    int t = r[i].sc;
    if (W >= w[t]) {
      W -= w[t]; V += v[t];
    } else {
      V += double((double)W/(double)w[t]*(double)v[t]);
      break;
    }
  }

  printf("%.6f\n", V);
  return 0;
}

Measured memory_bytes: 3412
open Batteries

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let s = scan "%s" identity

let () =
  let n = String.length s in
  let length i j =
    let sub = String.slice ~first:i ~last:j s in
    if List.for_all
        (fun c -> c = 'A' || c = 'C' || c = 'G' || c = 'T')
      @@ String.to_list sub then
      String.length sub else 0 in
  let rec aux f i j =
    if j > n then
      if i > n - 1 then []
      else
        aux f (i+1) (i+2)
    else
      (f i j) :: aux f i (j+1)
  in
  Printf.printf "%d\n" @@ List.max @@ aux length 0 1


Measured memory_bytes: 3072
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  7 20:52:12 2019

@author: YudNK
"""

N,D = map(int, input().split())
point = []
for i in range(N):
    l = [int(i) for i in input().split()]
    point.append(l)

def norm(i,j):
    norm2 = 0
    for k in range(D):
        norm2 += (i[k] - j[k])**2
    return norm2**0.5

count = 0
while len(point) > 1:
    for i in range(len(point) - 1):
        a = norm(point[-1],point[i])
        if a*10%10 == 0:
            count += 1
    point.pop(-1)
print(count)

Measured memory_bytes: 3188
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]  # 最短距離らしきもの

for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                # 更新されてはいけない
                print(-1)
                exit()

ans = sum([sum(a) for a in A])
for i in range(N):
    for j in range(N):
        for k in range(N):  # どの頂点を中継するかを、(i, j)について全探索
            if i == k or k == j:
                continue

            if A[i][j] == A[i][k] + A[k][j]:
                # A[i][j]となる辺はいらない
                ans -= A[i][j]
                break

print(ans // 2)


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

int main(){
    int A[5][4][11],n;
    for (int i=1;i<=4;i++)
       for (int j=1;j<=3;j++)
           for (int k=1;k<=10;k++) A[i][j][k]=0;
           
    cin>>n;
    for (int i=0;i<n;i++){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        A[b][f][r] += v;
        
    }
        
    for (int f=1;f<=4;f++){
        if (f>1) cout<<"####################\n";
        for (int b=1;b<=3;b++){
            for (int r=1;r<=10;r++){
                cout<<" "<<A[f][b][r];
            }
            cout<<endl;
            
        }
    }  
    return 0;    
}


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

int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        ans += min(x, k - x) * 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int x = tmp[0], a = tmp[1];
        WriteLine(x < a ? 0 : 10);
    }
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    vector<int> xs(N + 1, 0);

    while (K--)
    {
        int d;
        cin >> d;

        while (d--)
        {
            int x;
            cin >> x;

            xs[x]++;
        }
    }

    auto ans = 0;

    for (int i = 1; i <= N; ++i)
        ans += (xs[i] == 0 ? 1 : 0);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  LL N;
  cin >> N;
  vector<string> s(N);
  REP(i,N)
  {
    cin >> s[i];
  }

  LL sum = 0;

  REP(i,N)
  {
    bool flag = true;
    REP(x,N){
      REP(y,N){
        if(s[(x+i)%N][y]!=s[(y+i)%N][x]){
          flag = false;
        }
      }
    }
    if(flag)
    {
      sum += N;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
#define hell 1000000007

using namespace std;
void solve()
{

ll int  m,i,j,k,d=1,b,c=0,sum=0,z=0,q,x=0,y=0,n;
cin>>n;
m=n%100;
n/=100;
if(!m and n>12) {cout<<"NA"; return;}
if(!n and m>12) {cout<<"NA"; return;}
if(!m and !n) {cout<<"NA"; return;}
if(!n and m<=12) {cout<<"YYMM"; return;}
if(!m and n<=12) {cout<<"MMYY"; return;
}

if((m>12 and n>12)) {cout<<"NA"; return;}
//if( m>12 and n>12 ) {cout<<"NA"; return;}
if(m>12 and n<=12) {cout<<"MMYY"; return;}
 if(n>12 and m<=12) {cout<<"YYMM"; return;}
if(n<=12 and m<=12) cout<<"AMBIGUOUS";
}



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

 int t=1;
//cin>>t;
 while(t--)
  solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	string s;
	getline(cin, s);
	for (string::iterator it = s.begin(); it != s.end(); it++) {
		char c = (char)*it;
		if (isalpha(c))
			if (isupper(c))
				*it = tolower(c);
			else
				*it = toupper(c);
	}
	cout << s << endl;

	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i=0; i<m; i++) {
    int k;
    cin >> k;
    sum += k;
  }
  if (sum <= n)
  cout << n-sum;
  else
  cout << "-1";
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
    int a,b;
    cin >>a >>b;

    if(a <= 5){
        printf("0\n");
    }else if(a <= 12){
       printf("%d\n", b/2);
    }else{
       printf("%d\n", b);
    }
    return 0;
}

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

using namespace std;

int main(){
    array<pair<long long,long long>,200000>n;
    long long N,sum = 0;
    bool flag = 0;

    cin>>N;
    for(int i = 0; i < N; i++){
        cin>>n.at(i).second>>n.at(i).first;
    }
    sort(n.begin(),n.end());
    for(long long i = 200000 - N; i < 200000; i++){
        sum = sum + n.at(i).second;
        if(sum > n.at(i).first) flag = 1;
    }
    if(flag == 1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> l(N);
  vector<ll> r(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&l[i]);
    scanf("%lld",&r[i]);
  }
  vector<ll> seat(100001, 0);
  for (int i=0; i<N; i++) {
    for (int j=l[i]; j<=r[i]; j++) {
      seat[j]=1;
    }
  }
  cout << accumulate(seat.begin(), seat.end(), 0) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 1024
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,th;
  cin >> n;
  ll x[n],h[n],y[n];
  ll idx=-1;
  bool can;
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i]!=0){
      idx = i;
    }
  }
  for(ll cx=0;cx<=100;cx++){
    for(ll cy=0;cy<=100;cy++){
      can = true;
      th = h[idx]+abs(x[idx]-cx)+abs(y[idx]-cy);
      for(int i=0;i<n;i++){
        ll nh = th-abs(x[i]-cx)-abs(y[i]-cy);
        if(h[i] != max(nh,0ll)){
          can = false;
          break;
        }
      }
      if(can){
        cout << cx<<" "<<cy<<" "<<th<<endl;
        return 0;
      }
    }
  }
}


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var dict = new Dictionary<string,int>();
            dict.Add("A",10);
            dict.Add("B",11);
            dict.Add("C",12);
            dict.Add("D",13);
            dict.Add("E",14);
            dict.Add("F",15);
            int A;
            int B;
            dict.TryGetValue(s[0],out A);
            dict.TryGetValue(s[1],out B);
            if(A>B){
                Console.WriteLine(">");
            }else if(A<B){
                Console.WriteLine("<");
            }else{
                Console.WriteLine("=");
            }
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 1001;
const int INF = INT_MAX/2-1;

int n;
pi p[N];

pi GET(int l, int r){
    return {p[l].fi, p[r].se};
}

int DIST(pi a, pi b){
    return abs(a.fi-b.fi) + abs(a.se-b.se);
}

int dp[N][N];
int dfs(int l, int r){
    if(dp[l][r]>=0) return dp[l][r];
    if(l == r) return 0;

    pi root = GET(l,r);

    int ret = INF;
    for(int i=l; i<r; ++i){
        ret = min(ret, dfs(l,i)+DIST(root,GET(l,i)) + dfs(i+1,r)+DIST(root,GET(i+1,r)));
    }
    // dbg(root);
    // printf(" %d %d :: %d\n",l,r,ret);
    return dp[l][r] = ret;
}

int main(){
    scanf(" %d", &n);
    rep(i,n){
        int x,y;
        scanf(" %d %d", &x, &y);
        p[i] = {x,y};
    }
    memset(dp,-1,sizeof(dp));
    printf("%d\n", dfs(0,n-1));
    return 0;
}



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

int main() {
	int n,m;
	cin >> n >> m;
	vector<int>v;
	for (int i = 1;i <= n * 2;i++)v.push_back(i);

	for (int x = 0;x < m;x++) {
		int s;
		cin >> s;
		if (s == 0) {
			vector<int>va;
			vector<int>vb;
			int a = v.size();
			for (int i = 0;i < a/2;i ++) { 
				va.push_back(v[i]); 
				vb.push_back(v[(a / 2) + i]);
			}

			for(int i=0;i<a;i++){			
				if (i % 2 == 0) { v[i] = va[i / 2]; }
				else { v[i] = vb[i / 2]; }
		}
	}

		else {
			for (int i = 0;i < s;i++) {
				v.push_back(v[0]);
				v.erase(v.begin());
			}
		}

	}

	for (int i = 0;i < 2 * n;i++)cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL unsigned long long
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 2e5 + 100;
char s[N], t[N];
int cnt[26], _cnt[26];
int main() {
	scanf("%s", s);
	scanf("%s", t);
	int n = strlen(s);
	for (int i = 0; i < n; i++) cnt[s[i]-'a']++;
	for (int i = 0; i < n; i++) _cnt[t[i]-'a']++;
	sort(cnt, cnt+26);
	sort(_cnt, _cnt+26);
	for (int i = 0; i < 26; i++) {
		if(cnt[i] != _cnt[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 640
X,N = map(int, input().split())
P = [int(i) for i in input().split()]

flag = [True] * 105
for p in P:
    flag[p] = False

ans = [float("inf"), 0]
for i in range(105):
    if not flag[i]: continue

    if ans[0] > abs(i - X):
        ans[0] = abs(i - X)
        ans[1] = i

print(ans[1])

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

typedef long long ll;
long long a, b;

long double get(ll num, ll m) {
	if (num <= 0)
		return 0;
	if (num >= m)
		return num + 1;
	else
		return num;
}

bool check(ll k) {
	if (get(k / 2 - 1, a) * get(k - k / 2 + 2, b) >= a * b)
		return 0;
	if (get(k / 2 + 1, a) * get(k - k / 2, b) >= a * b)
		return 0;
	if (get(k / 2, a) * get(k - k / 2 + 1, b) >= a * b)
		return 0;
	if (get((k + 1) / 2, a) * get(k - (k + 1) / 2 + 1, b) >= a * b)
		return 0;
	if (a <= k && get(a, a) * get(k - a + 1, b) >= a * b)
		return 0;
	if (b <= k && get(k - b + 1, a) * get(b, b) >= a * b)
		return 0;
	return 1;
}
void solve() {
	cin >> a >> b;
	ll s = 0, e = 1e10;
	while (s + 1 != e) {
		ll mid = (s + e) / 2;
		if (check(mid))
			s = mid;
		else
			e = mid;
	}
	cout << s << '\n';
}

int main() {
	int t;
	cin >> t;
	while (t--)
		solve();
}

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

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    int ans = 0;
    if (a + w < b) {
        ans = b - (a + w);
    } else if (b + w < a) {
        ans = a - (b + w);
    } else {
        ans = 0;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
	int f = 1;
	char S[101];
	scanf("%s",S);
	for (int i = 0; i < 101; ++i){
		if (i % 2 == 0){
			if (S[i] == 'L'){
				f = 0;
			}
		}else if(i % 2 == 1){
			if (S[i] == 'R'){
				f = 0;
			}
		}
	}
	if (f == 1){
		printf("Yes");
	}else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    k = int(input())
    ichi = 0
    for s_ in s:
        if s_ == '1':
            ichi += 1
        else:
            break
    if ichi >= k:
        print(1)
    else:
        print(s[ichi])
if __name__ == '__main__':
  main()


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

int main() {
  string s;
  cin>>s;
  int kotae=0;
  if(s[0]=='1')kotae++;
  if(s[1]=='1')kotae++;
  if(s[2]=='1')kotae++;
  cout<<kotae<<endl;
  return 0;
}
  

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

long long gcd(long long a,long long b){
	if(b==0){
		return a;
	}else{
		return gcd(b,a%b);
	}	
}

int main(void){
    int N;long long ans=1;
    cin>>N;
    
    for(int i=0;i<N;i++){
        long long t;
        cin>>t;
        ans=(ans/gcd(ans,t)*t);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define TMP 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	ll ans = b / x - ((a == 0) ? -1 : (a - 1) / x);
	cout << ans << endl;
	return 0;
} 

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int r, g;
    cin >> r;
    cin >> g;
    cout << 2 * g - r << endl;
    return 0;
}

Measured memory_bytes: 256
d = input()
if d == "SUN":
  print(7)
if d == "MON":
  print(6)
if d == "TUE":
  print(5)
if d == "WED":
  print(4)
if d == "THU":
  print(3)
if d == "FRI":
  print(2)
if d == "SAT":
  print(1)

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

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

	bool t = false;

	for (char x : N) {
		if (x == '7') {
			t = true;
			cout << "Yes" << endl;
			break;
		}
	}

	if (!t) cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
#pragma region template 2.0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    ll N;
    cin >> N;
    vi A(N);
    FOR(i, A)
    {
        cin >> i;
    }

    map<ll, map<ll, ll>> dp;
    REP1(i, N)
    {
        for (ll j = i / 2; j <= (i + 1) / 2; ++j)
        {
            if (j == 0)
            {
                continue;
            }
            dp[i][j] = dp[i - 2][j - 1] + A[i - 1];
            if (j == i / 2)
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
        }
    }

    OUT(dp[N][N / 2]);
}

Measured memory_bytes: 42328
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[float("inf")]*n
cost[0]=0

for i in range(n):
    for j in range(1,k+1):
        if i+j>n-1:
            continue
        else:
            cost[i+j]=min(abs(h[i+j]-h[i])+cost[i] ,cost[i+j])

print(cost[n-1])


Measured memory_bytes: 55392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0;i<n;i++)cin >> a[i];
	sort(a.begin(),a.end());
	vector<ll> sum(n+1);
	for(int i=0;i<n;i++)
	{
		sum[i+1] = a[i]+sum[i];
	}
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		ll now = a[i];
		while (1)
		{
			auto hoge =	upper_bound(a.begin(),a.end(),now*2);
			if(now!=*(hoge-a.begin()+sum.begin()))
			now = *(hoge-a.begin()+sum.begin());
			else
			break;
			
			//cout<<now<<endl;
		}
		if(sum[n]==now)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main( int argc, char *argv[] )
{
int i;
int a;
int N;
int iSum;
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;

	iSum = 0;
	a = N;
	while( a > 0 )
	{
		iSum += a % 10;
		a /= 10;
	}

	if( N % iSum == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3030, inf = 1<<30;
int f[maxn][maxn + maxn];
int main(){
	int n, t;
	cin >> n >> t;
	vector<pair<int, int> > p;
	for(int i = 0; i < n; i++){
		int a, b; cin >> a >> b;
		p.push_back({a, -b});
	}
	sort(p.begin(), p.end());
	for(int i = 0; i < n; i++){
		int a, b; tie(a, b) = p[i]; b *= -1;
		for(int j = 0; j <= 2 * t; j++){
			f[i+1][j] = max(f[i+1][j], f[i][j]);
			if(j < t){
				int nj = min(j + a, 2 * t);
				f[i+1][nj] = max(f[i+1][nj], f[i][j] + b);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= 2 * t; i++) ans = max(ans, f[n][i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 71936
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int h,w;
int c[1500][1500];
int ans;

int main(){
  ans=0;
  memset(c,-1,sizeof(c));
  
  scanf(" %d %d",&h,&w);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf(" %d",&c[i][j]);
      if(c[i][j]==1)c[i][j]=-1;
      else if(c[i][j]==0)c[i][j]=1;
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i>0 && j>0 &&c[i][j]!=-1 && c[i][j-1]!=-1 &&
         c[i-1][j]!=-1 && c[i-1][j-1]!=-1){
        c[i][j]=min(c[i][j-1],min(c[i-1][j],c[i-1][j-1]))+1;
      }
      ans=max(ans,c[i][j]);
    }
  }
  
  printf("%d\n",ans*ans);

  return 0;
}

Measured memory_bytes: 12004
# frozen_string_literal: true

X = gets.chomp.to_i

def next_prime(num)
  return num if num == 2
  return num unless (2..((num / 3) + 1)).any? { |i| (num % i).zero? }

  num += 1
  next_prime(num)
end

puts next_prime(X)


Measured memory_bytes: 2044
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647;
const long long int llINF = 9223372036854775807;

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, n, m) for (ll i = (n); i < (m); i++)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()))
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()))

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

template <typename T, typename U> U READ(ll V, T a, U b) {
  REP(i, V) {
    cin >> a;
    b.push_back(a);
  }
  return b;
}

int main() {
  ll N = 0;
  vector<ll> A;
  vector<unsigned long long int> B;
  unsigned long long int sum = 0;
  ll po = 0;
  cin >> N;
  REP(i, N) {
    cin >> po;
    A.push_back(po);
    sum += po;
    B.push_back(sum);
  }
  ll mi = llINF;
  FOR(i, 1, N - 1) {
    ll left = B[i];
    ll right = B[N - 1] - B[i];
    ll lh = left / 2, rh = right / 2;
    ll l1 = lower_bound(B.begin(), B.begin() + i, lh) - B.begin();
    ll l2 = lower_bound(B.begin() + i + 1, B.end(), left + rh) - B.begin();
    ll w[2] = {0, -1};
    REP(k, 4) {
      vector<ll> pa(4);
      pa[0] = B[l1 + w[k % 2]];
      pa[1] = B[i] - B[l1 + w[k % 2]];
      pa[2] = B[l2 + w[k / 2]] - B[i];
      pa[3] = B[N - 1] - B[l2 + w[k / 2]];
      if (MIN(pa) == 0 || (l1 == 0 && k % 2 == 1) || (l1 == i && k % 2 == 0) ||
          (l2 == i + 1 && k / 2 == 1) || (l2 == N - 1 && k / 2 == 0)) {
        continue;
      }
      mi = min(mi, MAX(pa) - MIN(pa));
    }
  }
  cout << mi << endl;

  return 0;
}


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

namespace AChangingACharacter
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var k = inputs[1];

            var s = Console.ReadLine().ToCharArray();
            
            // K 番目の文字を小文字に変換
            s[k - 1] = char.ToLower(s[k - 1]);

            // 解答の出力
            Console.WriteLine(String.Concat(s));
        }
    }
}


Measured memory_bytes: 11348
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void sort(int a[]) {
		int n = a.length;
		if (n == 0) {
			return;
		}
		for (int i = 1; i < n; i++) {
			int j = i;
			int ca = a[i];
			do {
				int nj = (j - 1) >> 1;
				int na = a[nj];
				if (ca <= na) {
					break;
				}
				a[j] = na;
				j = nj;
			} while (j != 0);
			a[j] = ca;
		}
		int ca = a[0];
		for (int i = n - 1; i > 0; i--) {
			int j = 0;
			while ((j << 1) + 2 + Integer.MIN_VALUE < i + Integer.MIN_VALUE) {
				j <<= 1;
				j += (a[j + 2] > a[j + 1]) ? 2 : 1;
			}
			if ((j << 1) + 2 == i) {
				j = (j << 1) + 1;
			}
			int na = a[i];
			a[i] = ca;
			ca = na;
			while (j != 0 && a[j] < ca) {
				j = (j - 1) >> 1;
			}
			while (j != 0) {
				na = a[j];
				a[j] = ca;
				ca = na;
				j = (j - 1) >> 1;
			}
		}
		a[0] = ca;
	}

	static void solve() throws Exception {
		int n = scanInt();
		int m = scanInt();
		int a[] = new int[2 * n];
		for (int i = 0; i < 2 * n; i++) {
			a[i] = scanInt();
		}
		sort(a);
		int l = 0, r = n;
		while (l < r) {
			int mid = (l + r + 1) >>> 1;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < 2 * mid; i++) {
				min = min(min, a[2 * n - i - 1] + a[2 * (n - mid) + i]);
			}
			if (min >= m) {
				l = mid;
			} else {
				r = mid - 1;
			}
		}
		int ans = 0;
		for (int i = 0; i < n - l; i++) {
			ans = max(ans, a[i] + a[2 * (n - l) - i - 1]);
		}
		for (int i = 0; i < l; i++) {
			ans = max(ans, a[2 * n - i - 1] + a[2 * (n - l) + i] - m);
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 50728
#include<stdio.h>

#define N 100
#define A 1000

int main(){
  int array[A];
  int value,num,i,j,k;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&array[i]);
  }

  for(i=0;i<num;i++){
    
    value = array[i];

    j = i-1;

    while(j >= 0 && array[j] >  value){
      array[j+1] = array[j];
      j--;
      array[j+1] = value;
    }
    
    for(k=0;k<num-1;k++){
      printf("%d ",array[k]);    
    }

    printf("%d",array[k]);   
    printf("\n");
      
  }

  return 0;
}

    



Measured memory_bytes: 2736
import sys
sys.setrecursionlimit(5000)

N = int(input())
A = [(int(a), i) for i, a in enumerate(input().split())]
A = sorted(A, reverse=True)

memo = {}

def solve(i, l, r):
    if i==N: return 0

    key = l*N+r
    if key in memo: return memo[key]
    
    a, loc = A[i]
    score_l = a*abs(l-loc) + solve(i+1, l+1, r)
    score_r = a*abs(r-loc) + solve(i+1, l, r-1)
    retval = max(score_l, score_r)
    memo[key]=retval
    
    return retval
    
print(solve(0, 0, N-1))


Measured memory_bytes: 253012
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
ll cnt[2001], used[2001][2001];
int main(){
	ll n, x, y;
	cin >> n >> x >> y;
	for(ll i = 1; i <= n; i++){
		ll ans = 0;
		for(ll j = 1; j <= n; j++){
			ll temp;
			if(used[i][j] || used[j][i]) continue;
			temp = abs(i - j);
			temp = min(temp, abs(i - x) + 1 + abs(j - y));
			temp = min(temp, abs(i - y) + 1 + abs(j - x));
			used[i][j] = true;
			used[j][i] = true;
			cnt[temp]++;
		}
	}
	for(int i = 1; i <= n - 1; i++){
		cout << cnt[i]<< endl;
	}
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define m_p make_pair
#define pb push_back
#define fi first
#define se second
#define cl clear
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
map<vector<ll>,int> go; 
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> vl;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		vl.push_back(a);
	}
	map<ll,ll> mp;
	ll cnt = 1;
	vector<ll> used;
	ll zhouqi;
	ll left=0;
	//第一步：计算传送规律 
	//第二步：存每一个数字的出现步数和所有我走过的地方 
	//第三步：求出周期的长度和周期前的长度 
	//第四步：求出我的第K个数字到底在哪里
	for(int i=0;;)
	{
		if(mp[i]>0)
		{
			zhouqi = cnt-mp[i];
			left = mp[i]-1;
			break;
		}
		mp[i] = cnt;
		used.push_back(i);
		i = vl[i]-1;
		cnt++;
	}
	if(k-1<left)
	{
		cout<<used[k]+1<<endl;
		return 0;
	}
	ll chu = (k-left)%zhouqi;
	cout<<used[chu+left]+1<<endl;
	return 0;
}

Measured memory_bytes: 18556
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vi v(2*n); rep(i,2*n)cin>>v[i];
    sort(all(v));
    int ans=0;
    for(int i=2*n-1; i>=0;i-=2)ans+=min(v[i],v[i-1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint qu[252521],dp[252521];
lint out[114514];
vector<pint> gr[252521];
int cal(lint x,int n){
	int lo=0,hi=n;
	while(hi>lo+1){
		int mi=(hi+lo)/2;
		if(qu[mi]>x) hi=mi;else lo=mi;
	}
	return lo;
}
int main()
{
	int q,n=0;lint m,a;
	scanf("%lld %d",&m,&q);
	rep(i,q){
		scanf("%lld",&a);
		while(n>0 && qu[n-1]>=a) n--;
		qu[n]=a;n++;
	}
	if(n<1 || qu[0]>m){
		for(int i=n;i>0;i--) qu[i]=qu[i-1];qu[0]=m;n++;
	}
	if(n<2){
		rep(i,(int)qu[0]) printf("1\n");
		REP(i,(int)qu[0],(int)m) printf("0\n");
		return 0;
	}
	int s=(int)qu[0];
	for(int i=n+s-2;i>=s-1;i--) qu[i]=qu[i-s+1];REP(i,1,s) qu[i-1]=i;n+=s-1;
	//cout<<s<<' '<<n<<endl;
	REP(i,s,n){
		lint x=qu[i];
		while(x>0){
			int it=cal(x,i);
			gr[i].pb(mp(it,x/qu[it]));
			x%=qu[it];
		}
	}
	/*rep(i,n){
		cout<<qu[i];
		rep(j,gr[i].size()) printf("(%lld,%lld)",gr[i][j].fi,gr[i][j].se);cout<<endl;
	}*/
	memset(dp,0,sizeof(dp));dp[n-1]=1;
	for(int i=n-1;i>=s;i--){
		rep(j,gr[i].size()) dp[gr[i][j].fi]+=dp[i]*gr[i][j].se;
	}
	memset(out,0,sizeof(out));
	rep(i,s) out[i]=dp[i];
	for(int i=s-1;i>0;i--) out[i-1]+=out[i];
	rep(i,(int)m) printf("%lld\n",out[i]);
}


Measured memory_bytes: 27136
#include <bits/stdc++.h>
#define mem(a) memset(a, 0, sizeof(a))
using namespace std;
typedef pair<int, int> Pii;
typedef long long LL;
const int MAXN = 2005;
const int inf = 0x3f3f3f3f;
const int Mod = 100000000;
LL a[MAXN];
int main()
{
    LL n, z, w;
    scanf("%lld %lld %lld", &n, &z, &w);
    for(int i=1;i<=n;++i)
        scanf("%lld", &a[i]);
    LL ans;
    ans=abs(w-a[n]);
    if(n!=1)
        ans=max(ans, abs(a[n]-a[n-1]));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var r = Console.ReadLine();
            Console.WriteLine(r.Replace("?","D"));
        }

    }
}

Measured memory_bytes: 29024
from numpy import*
h,*s=open(0)
h,w=int32(h.split())
s=int32([[u>'#'for u in t]for t in s])
a,b,c,d=eval('copy(s),'*4)
for i in range(1,h+w):
 if i<w:a[:,i],b[:,~i]=-~a[:,i-1]*s[:,i],-~b[:,-i]*s[:,~i]
 if i<h:c[i,:],d[~i,:]=-~c[i-1,:]*s[i,:],-~d[-i,:]*s[~i,:]
print(amax(a+b+c+d)-3)

Measured memory_bytes: 122032
# -*- coding: utf-8 -*-
# I-Coin

'''
5
0.42 0.01 0.42 0.99 0.42
'''


N = int(input())
p = list(map(float, input().split()))

dp = [[0] * (N+1) for i in range(N+1)]

# i=0: 0枚中j(>0)枚が表の確率 = 0
dp[0][0] = 1

# j=0: i(>0)枚中0枚が表の確率 = 全て裏の確率
for i in range(1, N + 1):
    dp[i][0] = dp[i - 1][0] * (1 - p[i - 1])

# 漸化式で更新
for i in range(1, N + 1):
    for j in range(1, N + 1):
        dp[i][j] = dp[i-1][j-1] * p[i - 1] + dp[i-1][j] * (1 - p[i - 1])

# print(dp)
print(sum(dp[N][int((N+1)/2):]))



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

    vector<ll> a(N);
    ll total=0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        total += a[i];
    }

    ll sunuke=a[0];
    ll arai=total-a[0];
    ll ans=abs(sunuke - arai);
    for (int i = 1; i < N-1; i++) {
        sunuke += a[i];
        arai -= a[i];
        ans = min(ans, abs(sunuke - arai));
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())

    if N == 1 and M == 1:
        print(1)
    elif N == 1:
        print(M - 2)
    elif M == 1:
        print(N - 2)
    else:
        print((N - 2) * (M - 2))


if __name__ == "__main__":
    main()


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

typedef long long ll;

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<int> b(n);
    for(i = 0;i < n;++i){
        if(i%2 == 0){
            b.at(i/2) = a.at(n-i-1);
        }else{
            b.at(n-1-i/2) = a.at(n-i-1);
        }
    }
    for(i = 0;i < n;++i){
        cout << b.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
H, W = map(int, input().split())
a = [list(map(int,input().split())) for _ in range(H)]

ans = []
for y in range(H):
  if y%2==0:
    for x in range(W):
      if a[y][x]%2:
        a[y][x] -= 1
        if x == W-1:
          if y == H-1:
            break
          a[y+1][x] += 1
          ans.append([y+1, x+1, y+2, x+1])
        else:
          a[y][x+1] += 1
          ans.append([y+1, x+1, y+1, x+2])
  else:
    for x in range(W)[::-1]:
      if a[y][x]%2:
        a[y][x] -= 1
        if x == 0:
          if y == H-1:
            break
          a[y+1][x] += 1
          ans.append([y+1, x+1, y+2, x+1])
        else:
          a[y][x-1] += 1
          ans.append([y+1, x+1, y+1, x])

print(len(ans))
for i in range(len(ans)):
  print(' '.join(map(str, ans[i])))

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

int k;
string S;
int main() {
    cin >> k;
    cin >> S;
    for(int i=0;i<k && i<S.size();++i) cout << S[i];
    if(S.size() > k) cout << "..." << '\n';
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
D = list(map(int, input().split()))
MOD = 998244353

nodes = [0] * N

for d in D:
  nodes[d] += 1

ans = 0
if nodes[0]==1 and D[0]==0:
  pre_n = 1
  ans = 1
  for n in nodes:
    ans = (ans * pre_n**n) % MOD
    pre_n = n

print(ans)

Measured memory_bytes: 13908
using System;

namespace _20200711_A
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力部
            int N;
            string input;
            int[] anser;

            input = System.Console.ReadLine();
            N = int.Parse(input);
            anser = new int[N + 1];
            for (int i = 0; i < N + 1; i++)
            {
                anser[i] = 0;
            }

            //計算部
            int ans = 0;
            for (int x = 1; x * x < N; x++)
            {
                for (int y = x; y * y < N; y++)
                {
                    for (int z = y; z * z < N; z++)
                    {
                        ans = x * x + y * y + z * z + x * y + y * z + z * x;
                        if (ans > N) continue;
                        if (x == y && y == z)
                        {
                            anser[ans]++;
                            continue;
                        }
                        if (x == y || y == z || z == x)
                        {
                            anser[ans] += 3;
                            continue;
                        }
                        anser[ans] += 6;
                    }
                }
            }
            //for(int i = 0; i < N; i++)
            //{
            //    if (!((i+1) % 2 == 1)) continue;
            //    if (!(a[i] % 2 == 1)) continue;
            //    anser++;
            //}


            //出力部
            for (int n = 1; n < N + 1; n++)
            {
                Console.WriteLine(anser[n].ToString());

            }

            input = System.Console.ReadLine();
        }
    }
}


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

int n,c;
int w[3][35];
int d[35][35];
int ans;

void dfs(int now,int sum,int col1,int col2){
    for(int j=1;j<c+1;j++){
        if(j!=col1 && j!=col2){
            int tmp=0;
            for(int k=1;k<c+1;k++)tmp += w[now][k]*d[k-1][j-1];
            if(now==0)dfs(1,tmp,j,0);
            if(now==1)dfs(2,sum+tmp,col1,j);
            if(now==2)ans=min(ans,sum+tmp);
        }    
    }
}

int main(){
    cin >> n >> c;
    for(int i=0;i<c;i++)for(int j=0;j<c;j++)cin >> d[i][j];
    int e;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        cin >> e;
        w[(i+j+2)%3][e]++;
    }
    ans=1e9;
    dfs(0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
from itertools import permutations
N = int(input())

counter = np.zeros(N, dtype=int)

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            res = x**2 + y**2 + z**2 + x * y + x * z + y * z
            if res <= N:  
                counter[res - 1] += 1

for c in counter:
    print(c)


Measured memory_bytes: 26808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
using namespace std;


int main()
{
    int n;
    cin >> n;
    int h[n];
    int k = 0;
    bool can = true;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        if(h[i] < k - 1){
            can = false;
            break;
        }
        k = max(k,h[i]);
    }
    if(can){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 640
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	long long n, mon;
	cin >> n;
	set<long long>s;
	mon = n;
	s.insert(n);
	for (int i = 0; i <= 1000000; ++i) {
		if (mon % 2 == 0) { mon /= 2; }
		else { mon = 3 * mon + 1; }
		s.insert(mon);
		if (s.size() != i + 2) {
			cout << i + 2 << endl;
			return 0;
		}
	}
}

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

int main() {
  
  char X, Y;
  cin >> X >> Y;
  
  if (X == Y) {
    cout << '=' << endl;
  }
  else if (X > Y) {
    cout << '>' << endl;
  }
  else {
    cout << '<' << endl;
  }
  
return 0;
}

Measured memory_bytes: 3580
ans=[]
week=[
      'Monday',         #0
      'Tuesday',        #1
      'Wednesday',      #2
      'Thursday',       #3
      'Friday',         #4
      'Saturday',       #5
      'Sunday'          #6
      ]
year=[
      2, 5, 6, 2, 4, 0, 2, 5, 1, 3, 6, 1
      ]
while True:
    month,day=map(int,raw_input().split())
    if month==0 and day==0:
        break
    ans.append(week[ (year[month-1] + day) %7])
    
for i in ans:
    print i

Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

vi g[maxn+5];
bool viz[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, m; cin >> n >> m;
  int i, j, z, a, b;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int cnt, ans = 0;
  function<void(int)> df = [&df, &cnt] (int nod) {
    viz[nod] = 1;
    cnt++;
    for (int nn: g[nod])
      if (!viz[nn]) df(nn);
  };
  for (i = 1; i <= n; i++)
    if (!viz[i]) {
      cnt = 0;
      df(i);
      ans = max(ans, cnt);
    }
  cout << ans;
  return 0;
}


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

using namespace std;
const int N = 200010;
int _w;

int n;
char str[N];

bool check( int l1, int r1, int l2, int r2 ) {
	if( (r1-l1) != (r2-l2) ) return true;
	if( l2 < 0 ) return false;
	for( int i = 0; i <= (r1-l1); ++i )
		if( str[l1+i] != str[l2+i] )
			return true;
	return false;
}

int f[N][3];

void dp() {
	f[0][0] = 0;
	for( int i = 1; i <= n; ++i )
		for( int j = 0; j < 3 && j < i; ++j ) {
			if( check(i-j, i, i-j-1, i-j-1) )
				f[i][j] = max( f[i][j], f[i-j-1][0] + 1 );
			if( check(i-j, i, i-j-2, i-j-1) )
				f[i][j] = max( f[i][j], f[i-j-1][1] + 1 );
			if( check(i-j, i, i-j-3, i-j-1) )
				f[i][j] = max( f[i][j], f[i-j-1][2] + 1 );
		}
	cout << *max_element(f[n], f[n]+3) << endl;
}

int main() {
	cin >> (str+1);
	n = (int)strlen(str+1);
	dp();
	return 0;
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int N,sum=0,ans=2020202021;
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    sum += vec[i];
  }
  int sumsum = 0;
  for(int i=0; i<=N; i++){
    sumsum += vec[i];
    ans = min(ans,abs(sum-sumsum*2));
  }
  cout << ans << endl;
}


Measured memory_bytes: 4840