akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			int[] a = strToIntArray(br.readLine());
			for (int i = 0; i < a[0]; i++) {
				String S = br.readLine();
				for (int j = 0; j < 2; j++)
					System.out.println(S);
			}

		} catch (Exception e) {
			System.err.println("Error:" + e.getMessage());
		}
	}

	static int[] strToIntArray(String S) {
		String[] strArray = S.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}


Measured memory_bytes: 9044
def main():
    N = int(input())
    if N==1:
        return 1
    else:
        L = [2, 1]
        for i in range(1,N):
            a = L[0] + L[1]
            L[0] = L[1]
            L[1] = a
        return L[1]    

print(main())



Measured memory_bytes: 2940
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int64_t n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) cout << 1 << endl;
  else if (n == 1 || m == 1) cout << n * m - 2 << endl;
  else cout << (n - 2) * (m - 2) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 200000 + 5;

int main(){
	string n;
	cin >> n;
	int k;
	cin >> k;
	int len = n.length();
	int sum;
	int z,z1;
	if (k == 1)
    	sum = 9 * (len - 1) + n[0] - '0';
  	else if (k == 2){
	    z = -1;
	    for(int i = 1; i < len; i++){
	    	if(n[i] > '0'){
	    		z = i;
	        	break;
	    	}
	    }
		sum = 81 * (len-1) * (len-2) / 2;
		sum += 9 * (len-1) * (n[0]-'1');
		if(z > 0){
	    	sum += n[z]-'0';
			sum += 9 * (len-z-1);
		}
	}
	else{
	    z = z1 = -1;
		for(int i = 1; i < len; i++){
	    	if(n[i] > '0'){
	        	if (z < 0)
	        		z = i;
	        	else if(z1 < 0)
	          		z1 = i;
			}  
    	}
	    sum = 729 * (len-1) * (len-2) * (len-3) / 6;
	    sum += 81 * (len-1) * (len-2) / 2 * (n[0]-'1');
	    if(z > 0){
		    sum += (n[z]-'1') * 9 * (len-z-1);
		    sum += 81 * (len-z-1) * (len-z-2) / 2;
		    if(z1 > 0){
				sum += n[z1]-'0';
				sum += 9 * (len-z1-1);
		    }
	    }
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

int main() {

    string N;
    cin >> N;

    int number = N.length();
    int n = 0;

    for (int i = 0; i < number; i++) {
        n += N[i] - '0';
    }

    if(n % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int h[n],dp[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	dp[0]=0,dp[1]=abs(h[1]-h[0]);
	for (int i = 2; i < n; ++i)
	{
		dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
n1 = int(input())#行
n2 = int(input())#列
n3 = int(input())#塗りつぶす

ans = int(0)

if n1 > n2:
  N = n3 / n1
  M = n3 // n1
  if N == M:
    ans = M
  else:
    ans = M + 1
else:
  N = n3 / n2
  M = n3 // n2
  if N == M:
    ans = M
  else:
    ans = M + 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> 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)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    vi a(9);
    rep(i, 9){
        cin >> a[i];
    }
    int n; 
    cin >> n;
    vi b(n);
    rep(i, n){
        cin >> b[i];
        rep(j, 9){
            if(b[i]==a[j]){
                a[j]=0;
            }
        }
    }
    if(a[0]==0&&a[4]==0&&a[8]==0){
        cout<<"Yes"<<endl;
    }else if(a[2]==0&&a[4]==0&&a[6]==0){
        cout<<"Yes"<<endl;
    }else if(a[0]==0&&a[1]==0&&a[2]==0){
        cout<<"Yes"<<endl;
    }else if(a[3]==0&&a[4]==0&&a[5]==0){
        cout<<"Yes"<<endl;
    }else if(a[6]==0&&a[7]==0&&a[8]==0){
        cout<<"Yes"<<endl;
    }else if(a[0]==0&&a[3]==0&&a[6]==0){
        cout<<"Yes"<<endl;
    }else if(a[1]==0&&a[4]==0&&a[7]==0){
        cout<<"Yes"<<endl;
    }else if(a[2]==0&&a[5]==0&&a[8]==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    string comp;
    if (a < b) {
        comp = "a < b";
    }
    else if (a==b) {
        comp = "a == b";
    }
    else {
        comp = "a > b";
    }
    cout << comp.c_str() << std::endl;
    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	int p;
	int M = 0;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> p;
		M = max(M, p);
		sum += p;
	}
	sum -= M;
	sum += M / 2;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A0523
Title: card game
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;
int card[201];
int turn;              // 1:taro 2:hanako
int maisu[3];
//
card_init()
{  
  int i;
  for(i=1;i<=2*n;i++)
    card[i]=2;
}
//
// -1:no upper card -2:end (empty)
//
int kiru(int turn,int ba)
{
  int i;
  for(i=1;i<=2*n;i++)
    if(card[i]==turn)
      goto NEXT;
  return(-2);
 NEXT:
  for(i=ba+1;i<=2*n;i++)
    if(card[i]==turn)
      {
	card[i]=0;
	return(i);
      }
  return(-1);
}
void print_result()
{
  int i,t1,t2;
  t1=0;t2=0;
  for(i=1;i<=2*n;i++)
    {
      if(card[i]==2)
	t1 += 1;
      if(card[i]==1)
	t2 += 1;
    }
  printf("%d\n",t1);
  printf("%d\n",t2);
}
sh_card()
{
  int i;
  for(i=1;i<=2*n;i++)
    printf("%d:",card[i]);
  printf("\n");
}
main()
{
  int i,w,ret;
  
  while(EOF!=scanf("%d",&n) && n)
    {
      //printf("N:%d",n);
      card_init();
      for(i=0;i<n;i++)
	{
	  scanf("%d",&w);
	  card[w] = 1;
	}
      maisu[1]=maisu[2]=n;
      turn = 1;ret=0;
      while(1)
	{
	  ret=kiru(turn,ret);

	  if(ret >=0)
	    maisu[turn]--;
	  //printf("T %d:R %d M %d\n",turn,ret,maisu[turn]);
	  if(maisu[turn]<=0)
	    {
	      print_result();
	      break;
	    }
	  if(ret==-1)ret=0;
	  turn=3-turn;
	}
    }
return(0);
}

Measured memory_bytes: 600
n = int(input())
a = list(map(int, input().split(" ")))

a_list = [a_i-i for a_i in a for i in range(-1, 2)]

d = dict()
for a_i in a_list:
	if a_i not in d:
		d[a_i] = 0
	d[a_i] += 1

print(max(d.values()))

Measured memory_bytes: 30184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  cout << min(a*b,c) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200005];
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int res = 0;
    for (int i = 1; i + k - 1 <= n; ++i) {
        int tmp = a[i + k - 1] - a[i];
        tmp += min(abs(a[i]), abs(a[i + k - 1]));
        if (i == 1) res = tmp;
        else res = min(tmp, res);
    }
    cout << res;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n]={};
    for(int i=0;i<n*(n-1)/2;i++){
        int t1,t2,s1,s2;
        cin >> t1 >> t2 >> s1 >> s2;
        if(s1>s2) a[t1-1]+=3;
        else if(s1<s2) a[t2-1]+=3;
        else {
            a[t1-1]++;
            a[t2-1]++;
        }
    }
    int b[n];
    for(int i=0;i<n;i++) b[i]=a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++){
        for(int j=n;j>=0;j--){
            if(b[i]==a[j]){
                b[i]=n-j;
                break;
            }
        }
    }
    for(int i=0;i<n;i++) cout << b[i] << endl;
    return 0;
}



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

int main()
{
    int w;
    vector<int> a(2);
    cin >> w >> a[0] >> a[1];
    sort(a.begin(),a.end());
    int b = a[0] + w;
    if(b < a[1]) cout << (a[1] - b) << endl;
    else cout << 0 << endl;
    

}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);


int main(){
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  ll bitsum = 0;
  rep(i, 0, n) bitsum ^= a.at(i);
  rep(i, 0, n){
    cout << (bitsum ^ a.at(i));
    if(i == n - 1) cout << endl;
    else cout << " "; 
  }
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  std::vector<size_t> a(n);
  std::for_each(a.begin(), a.end(), [](auto& x){std::cin >> x, x--;});
  std::vector<size_t> ret{};
  auto err = [&] {
    std::cout << -1 << std::endl;
    exit(0);
  };
  while (!a.empty()) {
    size_t n = a.size();
    bool flag = false;
    for (size_t i = n - 1; i < n; i--) {
      if (a.at(i) == i) {
        a.erase(a.begin() + i);
        ret.push_back(i);
        flag = true;
        break;
      }
    }
    if (!flag) err();
  }
  assert(ret.size() == n);
  std::reverse(ret.begin(), ret.end());
  std::for_each(ret.begin(), ret.end(), [](auto& x){x++;});
  for (size_t i = 0; i < n; i++) {
    std::cout << (i > 0 ? " " : "") << ret.at(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> c(n-1),s(n-1),f(n-1);
  for(int i=0;i<n-1;i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  for(int i=0;i<n;i++){
    int t=0;
    for(int j=i;j<n-1;j++){
      if(t<s[j]){
        t=s[j];
      }
      else if(t%f[j]==0){
      }
      else{
        t=t+f[j]-t%f[j];
      }
      t+=c[j];
    }
    cout << t << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n, q;
    cin >> n >> q;
    ll ans = 0;
    map<int, int> mr, mc;
    mr[n] = n-2;
    mc[n] = n-2;
    while(q--) {
        int qt, x;
        cin >> qt >> x;
        if (qt == 1) {
            auto it = mc.lower_bound(x);
            if (it != mc.begin()) {
                it--;
                ans += it->second;
            } else {
                mc[x] = mr.begin()->first - 2;
                ans += mc[x];
            }
        } else {
            auto it = mr.lower_bound(x);
            if (it != mr.begin()) {
                it--;
                ans += it->second;
            } else {
                mr[x] = mc.begin()->first - 2;
                ans += mr[x];
            }
        }
    }
    cout << ll(n-2) * (n - 2) - ans << endl;
}


Measured memory_bytes: 12952
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(m*i+n*j-2*i*j == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let list = [];
    
    for(let i in A) {
        let temp = A[i] - (parseInt(i) + 1);
        
        list.push(temp);
    }
    
    let b = list.sort((a,b)=>a-b)[Math.floor(N / 2)];
    
    let answer = 0;

    for(let i in A) {
        let temp = Math.abs(A[i] - ((parseInt(i) + 1) + b));
        
        answer += temp;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 54920
#include<iostream>
#include<string>
bool check_palindrome(std::string str){
  int l=str.length();
  bool flag=false;
  for(int i=0, j=l-1; i<(l/2), j>(l/2); ++i, --j){
    if(str[i] != str[j]){
      flag=false;
      break;
    }
    else
      flag=true;
  }
  if(l==1)
    flag=true;
  return flag;
}
int main(){
  std::string str;
  std::cin>>str;
  int l=str.length();
  bool first = check_palindrome(str);
  bool second = check_palindrome(str.substr(0,(l-1)/2));
  bool third = check_palindrome(str.substr(((l+3)/2)-1, (l-1)/2));
  if(first && second && third && (l%2 != 0))
    std::cout<<"Yes"<<std::endl;
  else
    std::cout<<"No"<<std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, x, y;
	while (cin >> a >> b >> c >> x >> y)
	{
		if ((a + b) / 2.0 > c)
		{
			if (a / 2.0 > c) a = c * 2;
			if (b / 2.0 > c) b = c * 2;
			int d = min(x, y);
			cout << d*c * 2 + (x - d)*a + (y - d)*b << endl;
		}
		else cout << a*x + b*y << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]

ab = sorted(ab, key=lambda x: x[1])
a_sum = 0
ans = 'Yes'
for i in range(n):
    a_sum += ab[i][0]
    if a_sum>ab[i][1]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 55264
n, a, b = map(int, input().split())
p = 1000000007
def fast_pow(x,n,p):
    ans = 1
    while(n > 0):
        if n & 1 == 1:
            ans = ans * x % p
        x = x * x % p
        n = n >> 1
    return ans

def comb_mod(n, k, mod):
    numerator = 1
    denominator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % mod
        denominator = (denominator * (i + 1)) % mod

    return (numerator * fast_pow(denominator, mod - 2, mod)) % mod

def factor(a,b):
    ans = 1
    for i in range(a, b+1):
        ans*=i
    return ans

total = (fast_pow(2,n,p) - 1) % p
case_a = comb_mod(n, a, p)
case_b = comb_mod(n, b, p)

print((total - case_a - case_b) % p)

Measured memory_bytes: 3064
n=int(input())
a = list(map(int,input().split()))
x=0
f=0
while f==0: #フラグが0の間はループを回す
    for i in range(len(a)): # リストを１つずつ探索していく
        if a[i]%2 == 0:
            a[i]=a[i]//2    #もしも偶数ならリストをかきかえる
        else: #1つでも奇数であれば終了
            f=1 #　フラグfを1にする
            break
        if i == n-1: #ループが最後まで回っていたら
            x+= 1 #成功回数を１増やす
print(x)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
 
typedef vector<vector<lint>> mat;
 
mat mul(mat &a, mat &b, lint mod){
    int n = a.size();
    int m = b[0].size();
    mat c = vector<vector<lint>>(n, vector<lint>(m, 0));
    rep(i, n)rep(j, m){
        lint t = 0;
        rep(k, b.size()) t = (t + a[i][k] * b[k][j] % mod) % mod;
        c[i][j] = t;
    }
    return c;
}
 
mat pow(mat a, lint k, lint mod){
    int n = a.size();
    mat b = vector<vector<lint>>(n, vector<lint>(n, 0));
    rep(i, n) b[i][i] = 1;
    while(k){
        if(k & 1) b = mul(b, a, mod), k -= 1;
        else a = mul(a, a, mod), k >>= 1;
    }
    return b;
}

lint powmod(lint x, lint n, lint mod){
  lint ret = 1;
  while(n > 0){
    if(n&1) ret *= x, ret %= mod, n -= 1;
    else x *= x, x %= mod, n >>= 1;
  }
  return ret;
}

int main(){
    int n, m, a, b, c, t;
    while(scanf("%d", &n) && n){
        scanf("%d%d%d%d%d", &m, &a, &b, &c, &t);
        if(n == 1){
            int s;
            scanf("%d", &s);
            printf("%d\n", s * powmod(b, t, m) % m);
            continue;
        }
        mat A = vector<vector<lint>>(n, vector<lint>(n, 0));
        mat s = vector<vector<lint>>(n, vector<lint>(1, 0));
        rep(i, n) scanf("%d", &s[i][0]);
        A[0][0] = A[n-1][n-1] = b;
        A[0][1] = c;
        A[n-1][n-2] = a;
        For(i, 1, n-1){
            A[i][i-1] = a;
            A[i][i] = b;
            A[i][i+1] = c;
        }
        A = pow(A, t, m);
        s = mul(A, s, m);
        printf("%lld", s[0][0]);
        rep(i, n-1) printf(" %lld", s[i+1][0]);
        printf("\n");
    }
}


Measured memory_bytes: 3260
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>

using namespace std;

int main(void){

    int n;
    cin>>n;
    vector<long long int> h(n);
    for(int i=0;i<n;i++){
        long long int a;
        cin>>a;
        h[i] = a;
    }
   
    int max = 0;
    int a = 0;
    
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]) a++;
        else {
            if(a>max) {
                max=a;
            }
            a = 0;
        }
        if(i==n-2){
            if(a>max) {
                max=a;
                a = 0;
            }
        }
    }

    cout<<max<<endl;
}


Measured memory_bytes: 1024
# ABC043C - いっしょ / Be Together (ARC059C)
def main():
    # find the min cost to rewrite all to i (min(A) <= i <= max(A))
    N, *A = map(int, open(0).read().split())
    ans = 1 << 60
    for i in range(min(A), max(A) + 1):
        ans = min(ans, sum((i - a) ** 2 for a in A))
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
    transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
    transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    x -= a;
    if(x >= 0 && x <= b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


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

int main(){
    
    int r,c;
    cin >> r >> c;
    int sheet[r+1][c+1];
    for(int i=0; i<r; i+=1){
        int sum=0;
        for(int j=0; j<c; j+=1){
            int value;
            cin >> value;
            sheet[i][j] = value;
            sum += value;
        }
        sheet[i][c] = sum;
    }
    
    for(int j=0; j<c+1; j+=1){
        int sum=0;
        for(int i=0; i<r; i+=1){
            sum += sheet[i][j];
        }
        sheet[r][j] = sum;
    }
    
    for(int i=0; i<r+1; i+=1){
        for(int j=0; j<c+1; j+=1){
            cout << sheet[i][j];
            if(j==c) break;
            cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
n = int(input())
d,x = map(int, input().split())
A = [int(input()) for i in range(n)]

L = []
for i in range(len(A)):
  a = d // A[i]
  if (a*A[i])+1 <= d:
    L.append(a+1)
  else:
    L.append(a)
print(sum(L) + x)

Measured memory_bytes: 3060
def main():
    a = input()
    p = len(a)
    ans =0
    for i in range(2**(p-1)):
        t =a[0]
        for j in range(p-1):
            if (i & 1 <<j):
                t = t + '+'
            t = t + a[j+1]
        ans += eval(t)
    print(ans)
if __name__ =='__main__':
    main()

Measured memory_bytes: 9124
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  vector<char> S(4);
  rep(i, 4) cin >> S[i];
  if (S[0]==S[1] || S[1]==S[2] || S[2]==S[3]) {
    cout << "Bad\n";
  } else {
    cout << "Good\n";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[300005];
int n, ans[300005], ans1[300005], mmax = 1e9+7;
int main()
{
	
	memset(ans, 0, sizeof(ans));
	memset(ans1, 0, sizeof(ans1));
	cin >> n >> str;
	for (int i = 1;i < n;i++)
	{
		if (str[i-1] == 'W')ans[i] += ans[i - 1] + 1;
		else ans[i] = ans[i - 1];
	}
	
	for (int i = n-2;i >=0;i--)
	{
		if (str[i+1] == 'E')ans1[i] += ans1[i + 1] + 1;
		else ans1[i] = ans1[i + 1];
		
	}
	for (int i = 0;i < n;i++)
	{
		if ((ans[i] + ans1[i]) < mmax)mmax = ans[i] + ans1[i];
	}
	cout << mmax;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n;
  cin >> n;
  
  ll A[n];
  for (int i=0;i<n;i++) cin >> A[i];
  
  ll cnt = 0;
  ll sum = 0;
  ll ans = n;
  ll top = 0;
  //cout << (2 ^ 1) << endl;
  
  for (int i=0;i<n;i++){
    while (i != top){
      //cout << i << " " << A[i] << " " << sum << " " << (sum ^ A[i]) << " " << (sum+A[i]) << endl;
      if ((sum ^ A[i]) == (sum + A[i])){
        cnt += 1;
        sum += A[i];
        ans += (cnt-1);
        break;
      }
      else{
        sum -= A[top];
        top += 1;
        cnt -= 1;
      }
    }
    if (i == top){
      sum += A[i];
      cnt += 1;
      //cout << cnt << endl;
    }
    //cout << i << " " << ans << endl;
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int ar[3];
    for(int i=0;i<3;++i) cin>>ar[i];
    sort(ar,ar+3);
	cout<<ar[0]+ar[1];
    return 0;
}

Measured memory_bytes: 3596
s = input()

def solve(s):
    i = 0
    n = len(s)

    while i < n:
        if s[i:i+5] == 'dream':
            if s[i+5:i+7] != 'er':
                i += 5
            elif i+7 < n and s[i+7] == 'a':
                i += 5
            else:
                i += 7
        elif s[i:i+5] == 'erase':
            if i+5 < n and s[i+5] == 'r':
                i += 6
            else:
                i += 5
        else:
            return False
    return True

if solve(s):
    print("YES")
else:
    print('NO')


Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
 
#define MINF -1e8
 
int a[4] = {0, 0, -1, 1};
int b[4] = {-1, 1, 0, 0};
 
int ss[50][50];
int d[50][50];
priority_queue<pair<int, pair<int, int> > > pq;
 
void search(int h, int w){
  pq.push(make_pair(0, make_pair(0, 0)));
  d[0][0] = 0;
 
  while(!pq.empty()){
    pair<int, pair<int, int> > u = pq.top(); pq.pop();
    pair<int, int> v = u.second;
 
    if (u.first < d[v.first][v.second]) continue;
 
    for (int i = 0; i < 4; i++){
      if (v.first + a[i] < 0 || v.first + a[i] >= h) continue;
      if (v.second + b[i] < 0 || v.second + b[i] >= w) continue;
      if (ss[v.first + a[i]][v.second + b[i]] == 0) continue;
      if (d[v.first + a[i]][v.second + b[i]] < u.first - 1){
        d[v.first + a[i]][v.second + b[i]] = u.first - 1;
        pq.push(make_pair(d[v.first + a[i]][v.second + b[i]], make_pair(v.first + a[i], v.second + b[i])));
      }
    }
  }
}
 
 
int main(){
  int h, w;
  int count = 0;
  scanf("%d %d", &h, &w);
  for (int i = 0; i < h; i++){
    char str[50];
    scanf("%s", str);
    for (int j = 0; j < w; j++){
      if (str[j] == '.') {
        ss[i][j] = 1;
        count++;
      }
      else ss[i][j] = 0;
      d[i][j] = MINF;
    }
  }
 
  search(h, w);
 
  if (d[h-1][w-1] == MINF){
    printf("-1\n");
  } else printf("%d\n", count + d[h-1][w-1] - 1);
 
  return 0;
}

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

int main(){
    int n;cin>>n;
    map<string,int> memo;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        memo[s]+=1;
    }
    
    int m=0;
    for(auto const& v:memo){
        m=max(m,v.second);
    }

    for(auto i=memo.begin();i!=memo.end();i++){
        if(i->second==m){
            cout<<i->first<<endl;
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

/**
 * mod int
 */
template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<998244353>;

void leave(string s) {
    cout << s << endl;
    exit(0);
}

int main() {
    lint n;
    cin >> n;

    vector<lint> d(n);
    for(auto& e : d)  cin >> e;

    if(d[0] != 0)  leave("0");

    map<lint, lint> mp;
    for(auto e : d)  mp[e]++;
 
    lint m = mp.size();
    for(lint i=0; i<m; i++) {
        if(mp.count(i))  continue;
        leave("0");
    }
    if(mp[0] >= 2)  leave("0");

    mint ans = 1;
    for(lint i=0; i+1<m; i++) {
        ans *= mint::pow(mint{mp[i]}, mp[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] >= h && b[i] >= w) {
				ans ++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 25428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static long[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextLongArray(N);

        System.out.println( solve() );
    }

    static long solve() {
        long ans = 0;
        while( true ) {
            long max = - Long.MAX_VALUE / 2;
            int maxIndex = -1;

            for (int i = 0; i < N; i++) {
                if( A[i] > max ) {
                    max = A[i];
                    maxIndex = i;
                }
            }

            if( max < N ) {
                break;
            }

            long d = max / N;
            for (int i = 0; i < N; i++) {
                if( i == maxIndex ) {
                    A[i] -= d * N;
                } else {
                    A[i] += d;
                }
            }
            ans += d;
        }

        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

struct BIT{
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

//  http://na-o-s.hateblo.jp/entry/2014/07/13/031143

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    string s;
    cin >> n >> s;
    vector<BIT> fenwick = vector<BIT>(26, BIT(n));
    REP(i,n){
        fenwick[s[i] - 'a'].add(i+1,1);
    }
    int32 q;
    cin >> q;
    REP(_,q){
        int32 t;
        cin >> t;
        if(t == 1){
            int32 i;
            char c;
            cin >> i >> c;
            fenwick[s[i-1] - 'a'].add(i,-1);
            fenwick[c-'a'].add(i,1);
            s[i-1] = c;
        }else{
            int32 l ,r;
            cin >> l >> r;
            int32 cnt = 0;
            REP(i,26){
                if(fenwick[i].sum(r) - fenwick[i].sum(l-1) > 0)cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 53660
#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<=a&&a<=b){
	cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(c<=b&&b<=a){
	cout<<c<<" "<<b<<" "<<a<<endl;
	}
	else if(b<c&&c<a){
	cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else {
	cout<<b<<" "<<a<<" "<<c<<endl;
	}
return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }

int main()
{
	int N, D;

	cin >> N >> D;

	int i = 1;
	while (true)
	{
		if (i >= (double)N / (double)(2 * D + 1))
			break;
		i++;
	}

	cout << i << endl;

	return 0;

}

Measured memory_bytes: 256
n = int(input())
ta = input().split()
h = input().split()

t = int(ta[0])
a = int(ta[1])
for i in range(n):
	h[i] = int(h[i])

tem = []#各地点の平均気温
for i in range(n):
	tem.append(t - (h[i]*0.006))

rem = []#各地点の平均気温とaの差の絶対値
for i in range(n):
	if tem[i] >= a:
		rem.append(tem[i] - a)
	else:
		rem.append(a - tem[i])

tmp = rem[0]
ans = 0
for i in range(1, n):#差が一番小さい地点を探す
	if tmp > rem[i]:
		tmp = rem[i]
		ans = i

print(ans+1)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#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--)
int main() {
	int n, w, h; cin >> n >> w >> h;
	int a[200003] = {}; int b[200003] = {};
	int x, y, z;
	rep(i, n) {
		cin >> x >> y >> z;
		x = 2 * x - 1;
		y = 2 * y - 1;
		z = 2 * z;
		int r = x - z;
		if (r < 0)r = 0; a[r]++;
		r = x + z;
		if (r > 2*w-1)r = 2*w-1; a[r+1]--;
		r = y - z;
		if (r < 0)r = 0; b[r]++;
		r = y + z;
		if (r > 2*h-1)r = 2*h-1; b[r+1]--;
	}
	rep1(i, 2*w-1) {
		a[i] += a[i - 1];
	}
	rep1(i, 2*h-1) {
		b[i] += b[i - 1];
	}
	bool f = true;
	rep(i, 2*w) {
		if (a[i] == 0)f = false;
	}
	if (f)cout << "Yes" << endl;
	else {
		f = true;
		rep(i, 2*h) {
			if (b[i] == 0)f = false;
		}
		if (f)cout << "Yes" << endl;
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4640
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=max(a)
ng=0
while ok-ng>1:
    mid=(ok+ng)//2
    cnt=0
    for i in range(n):
        num=a[i]
        cnt+=-(-num//mid)-1
    if cnt<=k:
        ok=mid
    else:
        ng=mid
print(ok)

Measured memory_bytes: 30788
import math
N = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
X_ans = 0
Y_ans = 0
used_numX = list()
used_numY =list()
for i in range(N-1):
    if(i == N-2):
        if(X[i]>X[i+1]):
            X_ans +=2
        else:
            X_ans +=1
        if(Y[i]>Y[i+1]):
            Y_ans +=2
        else:
            Y_ans +=1


    else:
        used_x = used_y =0
        for j in range(len(used_numX)):
            if(used_numX[j]<=X[i]):
                used_x +=1
            if(used_numY[j]<=Y[i]):
                used_y +=1
    
        X_ans += math.factorial(N-1-i)*(X[i]-1-used_x)
        Y_ans += math.factorial(N-1-i)*(Y[i]-1-used_y)
        used_numX.append(X[i])
        used_numY.append(Y[i])

print(abs(X_ans-Y_ans))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  vector<int> A(3);
  cin>>A[0]>>A[1]>>A[2];
  
  sort(A.begin(),A.end());

  if((A[0]+A[1])%2==0){
    cout<<(2*A[2]-A[1]-A[0])/2<<endl;
  }else{
    cout<<(2*A[2]-A[1]-A[0]+3)/2<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    s,w = map(int, input().split())
    if w>=s:
        print("unsafe")
    else:
        print("safe")

if __name__=="__main__":
    main()


Measured memory_bytes: 65332
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    ll a, b;
    cin >> a >> b;
    cout << max({(a+b), (a-b), (a*b)}) << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

f [] _ = 0
f (x:xs) (y:ys) = if x > y then x - y + f xs ys else f xs ys

main = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    v <- fmap (read :: String -> Int) . words <$> getLine
    c <- fmap (read :: String -> Int) . words <$> getLine
    print $ f v c



Measured memory_bytes: 636
n,m=[int(x) for x in input().split()]
x=[int(x) for x in input().split()]
y=[int(x) for x in input().split()]
mod=10**9+7
ans=0
ysum=0
for j in range(1,m):
    ysum+=(y[j]-y[j-1])*j*(m-j)
for i in range(1,n):
    ans=ans+(x[i]-x[i-1])*i*(n-i)*ysum
print(ans%mod)

Measured memory_bytes: 84196
s = input()
mod = 10 ** 9 + 7

dp = [[0] * 13 for i in range(len(s))]
if s[0] == '?':
    dp[0] = [1] * 10 + [0] * 3
else:
    dp[0] = [int(i == int(s[0])) for i in range(13)]

for i, si in enumerate(s[1:], 1):
    for j in range(13):
        if si == '?':
            for k in range(10):
                dp[i][(10 * j + k) % 13] += dp[i - 1][j]
                dp[i][(10 * j + k) % 13] %= mod
        else:
            dp[i][(10 * j + int(si)) % 13] += dp[i - 1][j]
            dp[i][(10 * j + int(si)) % 13] %= mod
print(dp[-1][5] % mod)


Measured memory_bytes: 96364
#include <bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin >> n;

    map<string, int> name_and_count;
    for (int i = 0; i < n; i++)
    {
        string input;
        cin >> input;
        name_and_count[input]++;
    }

    int max = 0;
    for (auto entry : name_and_count)
    {
        if (entry.second > max)
            max = entry.second;
    }

    for (auto entry : name_and_count)
    {
        if (entry.second == max)

            cout << entry.first << endl;
    }
}


Measured memory_bytes: 25216
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  long long H;
  long long c = 1;
  long long res = 0;
  rd(H);
  while(H){
    res += c;
    H /= 2;
    c *= 2;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// {
//   ll H, c = 1, res = 0;
//   rd(H);
//   while(H){
//     res += c;
//     H /= 2;
//     c *= 2;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(s, c);
    if (s + s > c) {
        cout << c/2 << endl;
    } else {
        int ret = s;
        c -= s+s;
        ret += c / 4;
        cout << ret << endl;
    }


    return 0;
}



Measured memory_bytes: 256
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
elif s == 'SAT':
    print(1)

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for (int r=0; r<N/R+1; ++r) {
        for (int g=0; g<N/G+1; ++g) {
            ll tmp = N - R*r - G*g;
            if (tmp >= 0 and tmp%B == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    // Failed to predict input format
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    using ss=set<int>;
    using vss=vector<ss>;

    vss V(26);
    for (int i = 0; i < S.size(); i++) {
        V[S[i] - 'a'].insert(i+1);
    }

    for (int j = 0; j < Q; j++) {
        int m;
        cin >> m;
        if (m == 1) {
            int i;
            char c;
            cin >> i >> c;
            if (S[i-1] == c) {
                S[i-1]=c;
            }else{
                char old=S[i-1];
                V[old-'a'].erase(i);
                V[c-'a'].insert(i);
                S[i-1]=c;
            }
        } else {
            int l ,r;
            cin >>l>>r;
            int ans=0;
            for(auto&& item : V){
                auto&& il=item.lower_bound(l);
                auto&& ir=item.upper_bound(r);
                if( il!=ir){
                    ans++;
                }
            }
            cout<<ans<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 24196