akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
ll dp[5001][5001];
ll b[5001][201];
int main(){
    int n,m;
    cin >> n >> m;
    vector<ll>a(n);
    rep(i,n-1)cin >> a[i+1];
    rep(i,n-1){
        a[i+1] += a[i];
    }
    rep(i,n){
        rep(j,m){
            cin >> b[i][j];
        }
    }
    rep(j,m){
        priority_queue<pair<ll,int> > pq;
        rep(i,n){
            pq.push(MP(b[i][j],i));
        }
        set<int>st;
        st.insert(-1);
        st.insert(n);
        while(!pq.empty()){
            auto x = pq.top();
            pq.pop();
            int id = x.second;
            auto xx = st.lower_bound(id);
            xx--;
            int left = (*xx);
            left++;
            xx++;
            int right = (*xx);
            right--;
            ll k = x.first;
            dp[left][id] +=k;
            dp[left][right+1] -=k;
            dp[id+1][id] -=k;
            dp[id+1][right+1] +=k; 
            st.insert(id);
        }
    }
    rep(i,n){
        rep(j,n){
            dp[i][j+1] += dp[i][j];
        }
    }
    rep(j,n){
        rep(i,n){
            dp[i+1][j] += dp[i][j];
        }
    }
    ll mx = 0;
    rep(i,n){
        rep(j,n){
            if(i<=j){
                chmax(mx,dp[i][j]-a[j]+a[i]);
                // cerr << i << " " << j << " " << dp[i][j]-a[j]+a[i] << endl;
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 206904
package main

import (
  "fmt"
  "math"
)

func main() {
  var a,b,h,m float64
  var angle, ans float64
  fmt.Scanf("%f %f %f %f", &a, &b, &h, &m)

  angle = calcAngle(h, m)
  ans = calcAns(float64(a), float64(b), angle)
  fmt.Println(ans)

  // fmt.Println(math.Sqrt(a*a + b*b - 2*a*b*math.Cos(diff(360*(h/12)+30*(m/60), 360*(m/60))*math.Pi/180)))
}

func diff(a, b float64) float64 {
	if a > b {
		return a - b
	}
	return b - a
}

func calcAngle(h, m float64) (ans float64) {
  // hAngle := h * 30 + 30 * m / 60
  // mAngle := m * 6
  hAngle := 360*(h/12)+30*(m/60)
  mAngle := 360*(m/60)
  if hAngle > mAngle {
    ans = float64(hAngle - mAngle)
  } else {
    ans = float64(mAngle - hAngle)
  }
  return ans
}

func calcAns(a float64, b float64, angle float64) (ans float64) {
  cos := math.Cos(angle*math.Pi/180)
  ans = math.Sqrt(a*a+b*b-2*a*b*cos)
  return ans
}


Measured memory_bytes: 1820
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    sort(All(s));
    s.erase(unique(All(s)),s.end());
    if(s.size()==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
x, n = map(int, input().split())

import sys

if n==0:
  print(x)
  sys.exit()
  
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(0, 102) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
print(ans)


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

int main() {
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a+b > c+d){
    cout << "Left" << endl;
  }
  else if(a+b < c+d){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
n = int(input())
p = [float(i) for i in input().split()]

dp = [[0.0 for _ in range(n+1)] for _ in range(n+1)] #dp[i枚投げる 1はじまり][j枚表の確率 1はじまり]

dp[0][0] = 1.0 #0枚投げて0枚表の確率は1

for i in range(n): #i+1枚目を投げる 1はじまり
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1.0 - p[i])

#print(dp)
ans = 0
for i in range(n//2+1, n+1):
    ans += dp[n][i]
print(ans)


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

  
  string S;
  cin >> S;
  
  map<string, string> weather;  
  weather["Sunny"] = "Cloudy";
  weather["Cloudy"] = "Rainy";
  weather["Rainy"] = "Sunny";
  
  cout << weather.at(S) << endl;
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
using namespace std;
vector<char>v1,v2;
vector<char>::iterator iter1;
vector<char>::reverse_iterator iter2;
int main()
{
    for(int i=1; i<=3; i++)
    {
        char x;
        cin>>x;
        v1.push_back(x);
    }
    for(int i=1; i<=3; i++)
    {
        char x;
        cin>>x;
        v2.push_back(x);
    }
    for(iter1=v1.begin(),iter2=v2.rbegin();
    iter1!=v1.end(),iter2!=v2.rend();iter1++,iter2++){
        if(*iter1!=*iter2){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";


    return 0;
}






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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(ll i=0; i<n; i++)
        cin>>h[i];
    ll cost[n];
    for(ll i=0; i<n; i++)
        cost[i] = INF;
    cost[0] = 0;
    for(ll i=1; i<n; i++)
    {
        ll temp = 0;
        for(ll j=i; j>0&&temp!=k; j--, temp++)
            cost[i] = min(cost[i], cost[j-1] + abs(h[j-1] - h[i]));
    }
    //for(ll i=0; i<n; i++)
    //    cout<<cost[i]<<"    ";
    cout<<cost[n-1];
}


Measured memory_bytes: 1792
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		string[] input = Console.ReadLine().Split(' ');
		int K = int.Parse(input[0]);
		int S = int.Parse(input[1]);
		int ans = 0;

        for(int i = 0; i <= K; i++)
		{
            for(int j = 0; j <= K; j++)
			{
				if (S - i - j <= K && S - i - j >= 0)
				{
					ans++;

				}
			}
		}
		Console.WriteLine(ans);

	}
}

Measured memory_bytes: 11092
N, K = map(int, input().split())

result = 0
for i in range(N+1)[1::]:
    prod = i
    cnt = 0
    if i >= K:
        result += (N - i + 1) / N
        break
    else:
        while True:
            prod *= 2
            cnt += 1
            if prod >= K:
                result += 1 / (N*(2**cnt))
                break
print(result)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         int n  = sc.nextInt();
         int a[] = new int[n];
         for(int i= 0; i<n ; i++){
                 a[i] = sc.nextInt();
         }
         double j = 0.0;
         for(int i= 0 ; i<n ; i++){
             j += (double)1/a[i];
         }
         System.out.println(1/j);
         
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int l = s.length();
	int c =0;
	for(int i=0;i<l;i++){
		if(s[i]!=t[i])
		 c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3852
"use strict"
function main(arg) {
    var data = arg.trim().split("\n").map(Number)
    data.shift()
    var v1Index = 0
    var v2Index = 0
    if (data[0] > data[1]) {
        v1Index = 0
        v2Index = 1
    } else {
        v1Index = 1
        v2Index = 0
    }
    for (var i = 2; i < data.length; i++) {
        var value = data[i]
        var v1Value = data[v1Index]
        var v2Value = data[v2Index]
        //
        if (value >= v2Value) {
            if (value >= v1Value) {
                // 1位だったとき
                v2Index = v1Index
                v1Index = i
            } else {
                // 2位
                v2Index = i
            }
        }
    }
    for (var i = 0; i < data.length; i++) {
        if (i === v1Index) {
            console.log(data[v2Index])
        } else {
            console.log(data[v1Index])
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 37056
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    ll a;
    string b;
    cin >> a >> b;
    string n = "";
    for(int i = 0; i < b.size(); i++){
        if(b[i] != '.') n += b[i];
    }
    ll nb = (ll)stoi(n);
    ll ans = a * nb / 100;
    /*
    ll b1 = (int) b;
    ll b2 = (int)(b * 10) % 10;
    ll b3 = (int)(b * 100) % 10;

    ll c = a * b2;
    ll d = a * b3;

    double b4 = c % 10 * 0.1;
    double b5 = d % 100 * 0.01;

    ll add = (int)(b4 + b5);

    ll ans = a * b1 + (a * b2 / 10) + (a * b3 / 100);
    ans += add;
    */

    cout << ans << endl;
}


Measured memory_bytes: 3628
#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 POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\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)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    string s;
    cin >> s;
    int32 l = 0;
    int32 cur = 0;
    REP(i,n){
        if(s[i] == '('){
            cur++;
        }else{
            cur--;
        }
        if(cur < 0){
            l++;
            cur = 0;
        }
    }
    REP(i,l)cout << '(';
    cout << s;
    REP(i,cur)cout << ')';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<limits.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int min = INT_MAX;
  for(int p = 0; p <= 1; p++){
    int ave = sum / n + p;
    int ans = 0;
    for(int i = 0; i < n; i++){
      ans += (a[i] - ave) * (a[i] - ave);
    }
    if(min > ans) min = ans;
  }
  cout << min << endl;

}


Measured memory_bytes: 256
from sys import stdin
import bisect

def main():
    input = stdin.readline
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [0] * (n + 1)
    for i in range(n):
        c[i + 1] = c[i] + a[i]
    d = [0] * (m + 1)
    for i in range(m):
        d[i + 1] = d[i] + b[i]
    cnt = 0
    for i in range(n + 1):
        if c[i] > k:
            break
        e = bisect.bisect_right(d, k - c[i])
        if cnt < i + e - 1:
            cnt = i + e - 1
    print(cnt)
main()

Measured memory_bytes: 47636
n = int(input())
c = {}
for i in range(n):
    s = input()
    if s in c:
        c[s] += 1
    else:
        c[s] = 1
max = 0
for k in c.keys():
    if c[k] > max:
        max = c[k]
hit = [k for k in c.keys() if c[k] == max]
hit.sort()
for i in range(len(hit)):
    print(hit[i])

Measured memory_bytes: 143836
n = int(input())
a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
ans = 0

for i in range(n):
    to_right = sum(a_1[:i+1])
    to_left = sum(a_2[i:])
    calc = to_right + to_left
    if calc > ans:
        ans = calc

print(ans)

Measured memory_bytes: 3064
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 1005, mod = 1e9 + 7;
char a[N][N];
int f[N][N];


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, w;
    cin >> h >> w;
    rep(i, 0, h) {
        cin >> a[i];
    }
    f[0][0] = 1;
    rep(i, 0, h) {
        rep(j, 0, w) {
            if(a[i][j] == '#') {
                continue;
            }
            if(i == 0 && j == 0) {
                continue;
            }
            if(i > 0) {
                f[i][j] = f[i - 1][j];
            }
            if(j > 0) {
                f[i][j] += f[i][j - 1];
                if(f[i][j] >= mod) {
                    f[i][j] -= mod;
                }
            }
        }
    }
    cout << f[h - 1][w - 1] << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, K;
  cin >> N >> K;
  ll R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  ll ans = 0;
  vector<char> kako(N);
  REP(i, K) {
    char c = T[i];
    if (c == 'r') {
      ans += P;
      kako[i] = 'p';
    } else if (c == 's') {
      ans += R;
      kako[i] = 'r';
    } else {
      ans += S;
      kako[i] = 's';
    }
  }
  for (int i = K; i < N; i++) {
    char c;
    if (T[i] == 'r')
      c = 'p';
    else if (T[i] == 's')
      c = 'r';
    else
      c = 's';
    if (c == kako[i - K]) {
      kako[i] = 'n';
    } else {
      kako[i] = c;
      if (c == 'r') {
        ans += R;
        
      } else if (c == 's') {
        ans += S;

      } else {
        ans += P;

      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)

using namespace std;
typedef long long int ll;

int main() {
	int n, q;
	cin >> n;
	queue<int> line;
	int c;
	line.push(0);
	c = 1;
	Loop(i, n) {
		int x;
		cin >> x;
		Loop(j, c) {
			int a = line.front();
			line.pop();
			line.push(a);
			line.push(a + x);
		}
		c *= 2;
	}
	cin >> q;
	Loop(i, q) {
		int y;
		cin >> y;
		bool judge = false;
		Loop(j, c) {
			int a = line.front();
			if (y == a) {
				judge = true;
				break;
			}
			else {
				line.pop();
				line.push(a);
			}
		}
		if (judge) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

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

class DisjointSet {
public:
  vector<int> p, rank, size;
  DisjointSet(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    size.assign(n, 0);
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }

  void make_set(int x) {
    p[x] = x;
    rank[x] = 0;
    size[x] = 1;
  }

  bool same(int x, int y) {
    return find_set(x) == find_set(y);;
  }

  int find_set(int x) {
    if (x != p[x]) {
      p[x] = find_set(p[x]);
    }
    return p[x];
  }

  int union_size(int x) {
    if (x != p[x]) {
      size[x] = union_size(find_set(x));
    }
    return size[x];
  }

  void link(int x, int y) {
    if(rank[x]  > rank[y]) {
        p[y] = x;
        size[x] = size[x] + size[y];
    }else if(rank[x] < rank[y]){
        p[x] = y;
        size[y] = size[x] + size[y];
    }else if(x != y) {
      p[y] = x;
      rank[x]++;
      size[x] = size[x] + size[y];
    }
  }

  void unite(int x, int y) {
    link(find_set(x), find_set(y));
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int X[M], Y[M], Z[M];
  int odd[N]{};
  int even[N]{};
  DisjointSet ds(N);
  for (int i = 0; i < M; i++) {
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;
    Y[i]--;
    if (Z[i] % 2 == 0) {
      even[X[i]] = 1;
      even[Y[i]] = 1;
    } else {
      odd[X[i]] = 1;
      odd[Y[i]] = 1;
    }
    ds.unite(X[i], Y[i]);
  }
  int p[N]{};
  for (int i = 0; i < N; i++) {
    if (even[i] * odd[i] == 1 ) {
      p[ds.find_set(i)] = 1;
    }
  }
  set<int> s;
  for (int i = 0; i < N; i++) {
    s.insert(ds.find_set(i));
  }
  cout << s.size() << "\n";

  return 0;
}

Measured memory_bytes: 8448
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
  bool p[3] = { true, false, false };
  char x, y;
  while (scanf("%c,%c\n", &x, &y) == 2)
    swap(p[x-'A'], p[y-'A']);
  if (p[0])
    puts("A");
  else if (p[1])
    puts("B");
  else
    puts("C");
  return 0;
}

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

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    for(int i=1;;i++)
    {
        if(x*i>=n)
            cout<<i*t<<"\n";
        else
            continue;
        break;
    }
}


Measured memory_bytes: 3620
import sys

n = int(sys.stdin.readline().rstrip())
xy = list(zip(*[map(int, sys.stdin.read().split())] * 2))

mask = (1 << 31) - 1
def solve(x, y, mode):
    u = x + y
    v = x - y
    if mode == 0:
        u -= 1
        v -= 1

    s = (u + mask) >> 1
    t = (v + mask) >> 1

    l = (~(s | t)) & mask
    r = s & t & mask
    d = (~s) & t & mask
    u = s & (~t) & mask

    res = ''
    for i in range(31):
        if l >> i & 1:
            res += 'L'
        elif r >> i & 1:
            res += 'R'
        elif d >> i & 1:
            res += 'D'
        elif u >> i & 1:
            res += 'U'
    if mode == 0:
        res += 'R'
    
    return [res]

def main():
    oe = (xy[0][0] + xy[0][1]) % 2
    for x, y in xy:
        if (x + y) % 2 != oe:
            print(-1)
            sys.exit()

    m = 31
    d = [2 ** i for i in range(31)]
    if oe == 0:
        d += [1]
        m += 1
    yield [m]
    yield d

    for x, y in xy:
        yield solve(x, y, oe)

if __name__ == '__main__':
    ans = main()
    for i in ans:
        print(*i, sep=' ')

Measured memory_bytes: 3316
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N, K;
const int Nmax=1e5;
string S;

int main(){
	cin >> N >> K;
	cin >> S;

	vector<int> x;
	if(S[0]=='0') x.push_back(0);
	int n = 1;
	for(int i=1; i<N; i++){
		if(S[i]!=S[i-1]){
			x.push_back(n);
			n = 1;
		} else {
			n += 1;
		}
	}
	x.push_back(n);

	//for(int i=0; i<x.size(); i++) cout << x[i] << endl;
	int sum = 0;
	//cout << N << " " << 2*K+1 << endl;
	for(int i=0; i<min((int)x.size(), 2*K+1); i++){
		sum += x[i];
	}
	//cout << sum << endl;

	int ans = sum;
	for(int i=0; i+2*K+1<x.size(); i+=2){
		sum -= x[i]+x[i+1];
		sum += x[i+2*K+1];
		if(i+2*K+2<x.size()) sum += x[i+2*K+2];
		ans = max(ans, sum);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	while (n > 0) {
		if (n % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3636
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", max(a + b, max(a - b, a * b)));

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#define rep(i,n)for(int i=0;i<n;i++)
#define l int64_t
using namespace std;l q,x,y,f[99]={0,1},m=1e9+7;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){printf("1 %d ",y==1?1:x==1?2:4);continue;}rep(j,99){if(x<f[j]||y<f[j+1]){l a=x==1?2:1;rep(k,j-2){l n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";j=99;}}}}

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

bool compare_by_b_decending(pair<int, int> a, pair<int, int> b){
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

int main(){
    // 入力
    int N; cin >> N;
    vector<pair<int, int> > red(N),blue(N);
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        red[i] = {a,b};
    }
    for(int i = 0; i < N; i++){
        int c, d; cin >> c >> d;
        blue[i] = {c,d};
    }
    sort(red.begin(), red.end(), compare_by_b_decending);

    vector<bool> used_red(N, false);
    priority_queue<
    pair<int,int>, 
    vector<pair<int,int>> ,
     greater<pair<int,int>>> PQ;
    for(int i = 0; i < N; i++ ) PQ.push(blue[i]);

    int ans = 0;
    while(!PQ.empty()){
        auto u = PQ.top(); PQ.pop();
        for(int i = 0; i < N; i++){
            if(red[i].first < u.first && red[i].second < u.second && used_red[i] == false){
                used_red[i] = true;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 550;
int N;
char a[MAX_N][MAX_N];

bool is_allB_R(const int k) {
    for (int i = 1; i <= N; i++) {
        if (a[k][i] == '.') {
            return false;
        }
    }
    return true;
}

bool is_allB_C(const int k) {
    for (int i = 1; i <= N; i++) {
        if (a[i][k] == '.') {
            return false;
        }
    }
    return true;
}

bool is_anyB_C(const int k) {
    for (int i = 1; i <= N; i++) {
        if (a[i][k] == '#') {
            return true;
        }
    }
    return false;
}

int cnt_W_R(const int k) {
    int ret = 0;
    for (int i = 1; i <= N; i++) {
        if (a[k][i] == '.') {
            ret++;
        }
    }
    return ret;
}

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            std::cin >> a[i][j];
        }
    }

    int num_br = 0;
    int num_bc = 0;

    for (int i = 1; i <= N; i++) {
        if (is_allB_R(i)) { num_br++; }
        if (is_allB_C(i)) { num_bc++; }
    }

    if (0 < num_br) {
        std::cout << N - num_bc << std::endl;
        return 0;
    }

    int tmp = N + 1;
    for (int i = 1; i <= N; i++) {
        if (is_anyB_C(i)) {
            tmp = std::min(tmp, cnt_W_R(i));
        } else if (cnt_W_R(i) < N) {
            tmp = std::min(tmp, cnt_W_R(i) + 1);
        }
    }

    if (tmp == N + 1) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::cout << tmp + N - num_bc << std::endl;
    return 0;
}

Measured memory_bytes: 512
N, Y = list(map(int, input().split()))
for x in range(N + 1):
    for y in range(N - x + 1):
        z = (N - x - y)
        if 0 <= z <= 2000 and Y == 10000 * x + 5000 * y + 1000 * z:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
# ITP1_5_C: Print a Chessboard

def make_line(width, is_even)
  o = is_even ? 0 : 1
  width.times.inject('') do |line, n|
    line << ( (n + o).even? ? '#' : '.' )
  end
end

while true
  height, width = gets.split.map &:to_i
  break if height == 0 && width == 0

  even_line = make_line width, true
  odd_line  = make_line width, false

  (height / 2).times do
    puts even_line, odd_line
  end
  puts even_line if height.odd?
  puts
end

Measured memory_bytes: 8652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  ll d = 'A' - 'a';
  cout << char(s1[0] + d) << char(s2[0] + d) << char(s3[0] + d) << endl;
}

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

int main() {
    string T;
    cin >> T;
    for(int i = 0; i < T.size(); i++) {
        if(T[i] == '?') {
            T[i] = 'D';
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 3752
#define debug 0
#include <iostream>
#include <string>
using namespace std;

bool case1(string);
bool case2(string);

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

  if ( case1(S) && case2(S) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

bool case1(string S)
{
  bool flag = 1;
  for (auto it=S.begin(); it<S.end(); it+=2 )
  {
    if (debug) cout << *it << endl;
    if (*it == 'L')
    {
      flag = 0;
    }
  }
  return flag;
}

bool case2(string S)
{
  bool flag = 1;
  for (auto it=S.begin()+1; it<S.end(); it+=2 )
  {
    if (debug) cout << *it << endl;
    if (*it == 'R')
    {
      flag = 0;
    }
  }
  return flag;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(S: str, T: str):
    ans = -1
    for i in range(len(S)-len(T)+1):
        sub = S[i:i+len(T)]
        m = 0
        for j in range(len(T)):
            if sub[j]==T[j]:
                m += 1
        ans = max(ans, m)
    print(len(T)-ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27144
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll a,b,n;
    scanf("%lld%lld%lld", &n, &a, &b);

    ll m=n/(a+b);
    ll ans=m*a+MIN(a,n%(a+b));
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
    solve();

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
l = gets.chop.split.map(&:to_i)

l.sort!
ans = 0

0.upto(n-3) do |i|
  (i+1).upto(n-2) do |j|
    a_b = l[i] + l[j]

    idx = l.bsearch_index{ |x| x >= a_b }

    # p "i:#{i} j: #{j} a+b:#{a_b} idx: #{idx}"

    if idx.nil?
      ans += n - j - 1
    else
      ans += idx - j - 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    int sum = 0, num = 1;
    for(; ; num++){
        sum += num;
        if(sum >= n)break;
    }
    vector<int> res;
    while(n>0){
        if(n-num>=0){
            res.push_back(num);
            n -= num;
        }
        num--;
    }
    reverse(all(res));
    for(auto a: res) cout << a << ln;
}

Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ld N ;
    cin >> N ;
    
    ld sum = 0 ;
    rep(i, N){
        ld inp;
        cin >> inp;
        sum +=(ld)1.0/inp;
    }


    cout << fixed << setprecision(16) << (ld)1.0 / sum << endl; 

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	ans := 0
	for {
		ok := true
		for i := 0; i < n; i++ {
			if as[i]%2 == 1 {
				ok = false
				break
			}
			as[i] /= 2
		}
		if !ok {
			break
		}
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	long H=sc.nextLong();
	long bunnum=0;
	while(H>1) {
		H/=2;
		bunnum++;
	}
	long play=(long) Math.pow(2, bunnum);
	System.out.println(2*play-1);


}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);
    sort(all(s));
    rep(i, n) cout << s.at(i);
    cout << endl;
    // end

    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)

int main(){
  int m,t,p,r;
  while(cin >> m >> t >> p >> r , m){
    vector<int> now(t);
    int p[100][20] ={};
    int ca[100] = {};
    int mm,tt,pp,jj;
    rep(i,r){
      cin >> mm >> tt >> pp >> jj;
      --tt;
      if(jj){
        p[tt][pp]++;
      }else{
        now[tt] += mm;
        now[tt] += p[tt][pp]*20;
        ca[tt]++;
      }
    }
    using tiii = tuple<int,int,int>;
    vector<tiii> ts;
    rep(i,t){
      ts.push_back(tiii{ca[i],-now[i],i+1});
    }
    sort(begin(ts),end(ts), greater<tiii>());
    rep(i,t-1){
      int a,b,c; tie(a,b,c) = ts[i];
      int aa,bb,cc; tie(aa,bb,cc) = ts[i+1];
      cout << c << ((a == aa && b == bb)?'=':',');
    }
    int a,b,c; tie(a,b,c) = ts[t-1];
    cout << c << endl;
  }
}



Measured memory_bytes: 3072
#include <stdio.h>

int main(){
  char c[1101];
  int i=0,ans=0,b=1;
  do{
    for(i=0; i<1100; i++){
      scanf("%c",&c[i]);
      if(i==0&&c[0]=='0'){
        b=0;
        break;
      }
      if(c[i]=='\n')break;
      ans+=(c[i]-'0');
    }
    if(b)printf("%d\n",ans);
    ans=0;
  }while(b);
  return 0;
}

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

int gcd( int x, int y){
  int r;
  if( x < y ) swap(x,y);

  while( y > 0 ){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main(){
  int a,b;
  while (cin >> a >> b ){
    cout << gcd(a,b) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);
        String str = sn.next();
        if( Character.isUpperCase( str.charAt( 0 ) ) ) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
	}
}



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

#define int long long

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, fl = 1, cnt = 1;
    cin >> n;
    
    vector<int> pre(n), suf(n), Max(n, -1), Min(n, -1);
    for (auto &x : pre) cin >> x;
    for (auto &x : suf) cin >> x;
    
    Max[0] = Min[0] = pre[0], Max[n - 1] = Min[n - 1] = suf[n - 1];
    if (pre[n - 1] > pre[n - 2]) fl = pre[n - 1] == suf[n - 1];
    
    for (int i = 1; i < n-1; ++i) {
        if (pre[i] > pre[i - 1]) Max[i] = Min[i] = pre[i];
        else Max[i] = pre[i], Min[i] = 1;
    }
    for (int i = n-2; i >= 0; --i) {
        if (suf[i] > suf[i + 1]) {
            fl &= Max[i] >= suf[i];
            Max[i] = Min[i] = suf[i];
        }
        else Max[i] = min(Max[i], suf[i]);
    }
    
    for (int i = 0; i < n; ++i) cnt = cnt * (Max[i] - Min[i] + 1) % mod;
    
    if (!fl) cout << 0 << "\n";
    else cout << cnt << "\n";
    
    return 0;
}

Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
signed main() {
	int n = read();
	vector<int>a(200000);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0 || a[i - 1] >= a[i]) ans++;
	}
	cout << ans << endl << n << endl;
}


Measured memory_bytes: 4424
import java.util.Scanner;

class Main {

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

        int h = sc.nextInt();
        int w = sc.nextInt();

        String[] c = new String[h];

        for (int i = 0; i < h; i++) {
            c[i] = sc.next();
        }

        for (int i = 0; i < h; i++) {
            System.out.println(c[i]);
            System.out.println(c[i]);
        }
    }
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

ll f(ll h) {
    if (h == 1) return 1;
    return 2 * f(h / 2) + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    cout << f(H) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;

ll mypow(ll n, ll m) {
    ll res = 1;
    n %= DIV;

    while (m) {
        if (m % 2) {
            res *= n;
            res %= DIV;
        }
        n *= n;
        n %= DIV;
        m /= 2;
    }

    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;

    //cout << mypow(K, N) << endl;
    ll ans = 0;
    vector<ll> cnt(K + 1);
    for (ll i = K; i >= 1; i--) {
        cnt[i] = mypow(K / i, N);
        for (ll j = 2; i * j <= K; j++) {
            cnt[i] -= cnt[i * j];
            if (cnt[i] < 0)cnt[i] += DIV;
            cnt[i] %= DIV;
        }
        ll temp = cnt[i] * i;
        temp %= DIV;
        ans += temp;
        ans %= DIV;
        //cout << "ans=" << ans << endl;
    }

    /*
    for (int i = 1; i <= K; i++) {
        printf("cnt[%d]=%lld\n", i, cnt[i]);
    }
    */
    cout << ans << endl;
}


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

int main() {
	int k,i,w=0;
	char s[20];
	cin >> s;
	k=strlen(s);
	for(i=0;i<k;i++){
		if(s[i]=='o') w++;
	}
	if(w+15-k>=8) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

ll gcd(ll a, ll b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
    init();

    int n, m; cin >> n >> m;
    VL a(n); cin >> a;

    set<int> c;
    FOR(i, 0, n)FOR(j, 0, 40)if (a[i] & (1LL << j)) {
        c.insert(j);
        break;
    }
    if (c.size() != 1) {
        cout << "0\n";
        return 0;
    }

    ll x = 1;
    FOR(i, 0, n)x = lcm(x, a[i]);
    if (x % 2 == 1) {
        cout << "0\n";
        return 0;
    }

    ll ans = (m + x / 2) / x;
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
 
int main()
{
    uint64_t m, n, all = 0;
    vector<int> vec;
 
    cin >> n >> m;
 
    for(int i = 0; i < n; ++i)
    {
        vec.emplace_back();
        cin >> vec.back();
        all += vec.back();
    }
 
    std::sort(vec.begin(), vec.end());
 
    for(int i = 0; i < m; ++i)
    {
        if(vec.back() < 1.*all / 4 / m)
        {
            cout << "No\n";
            return 0;
        }
        vec.pop_back();
    }
 
    cout << "Yes\n";
 
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()

b = []
c = 0
for i in range(n):
    c += a[i]
    b.append(c)
a.sort(reverse=True)
b.sort(reverse=True)

d = 0
for i in range(1,n):
    if b[i]*2 < a[i-1]:
        d = i
        break
        
if d:
    print(d)
else:
    print(n)

Measured memory_bytes: 14636
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e13+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
//ll a[200001]={0};
//ll b[100001]={0};

//bool c[1000001]={0};
//vector<pair<ll,ll> > adj[100001];
vector<ll> adj[200001];
//vpii edges;
bool visited[200001]={0};
//bool color[200001]={0};
//ll dist[100001]={0};
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr);
        }
    }
}*/

/*void dfs(ll x,ll y){
    if(x<0 || y<0 || x>=n || y>=m)return;
    //if(grid[x][y]!=color)return;
    if(visited[x][y] || Map[x][y]=='#'){
        //f=true;
        return;
    }
    visited[x][y]=true;
    Map[x][y]='#';
    //if(px!=(x+1) || py!=y)
        dfs(x+1,y);
    //if(px!=(x-1) || py!=y)
        dfs(x-1,y);
    //if(px!=(x) || py!=y+1)
        dfs(x,y+1);
    //if(px!=(x) || py!=y-1)
        dfs(x,y-1);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};
ll dp[100001]={0};

void dfs(ll s){
    if(visited[s])return;
    visited[s]=true;
    for(auto u:adj[s]){
        dfs(u);
        dp[s]=max(dp[s],1+dp[u]);
    }
}
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

void solve(){
    ll n,m;
    cin>>n>>m;
    ll a,b;
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        adj[a].push_back(b);
    }

    for(ll i=1;i<=n;i++){
        if(!visited[i]){
            dfs(i);
        }
    }
    cout<<*max_element(dp,dp+100001);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //sieve(1000001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 14256
s=list(input())
from copy import copy
t=s.copy()

for i in range(len(t)):
  p=int(len(s)/2)
  if len(s)%2==0 and s[:p]==s[p:] and len(s)!=len(t):
    print(len(s))
    exit()
  else:
    s.pop(-1)
    

Measured memory_bytes: 9192
#include<iostream>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define fr first
#define sc second
typedef pair< int , int > P;
int n, m;
deque< P > d;
int _sum(P p){
  return p.sc - p.fr + 1;
}
int query(int& p,int& q,int& r){
  int ret = 0, ans = 0;
  while(ret + _sum(d.front()) < p){
    ret += _sum(d.front());
    d.pop_front();
  }
  if(ret != p - 1) d.front().fr += p - ret;
  ret = p;
  while(ret + _sum(d.front()) <= q){
    if(d.front().sc <= r) ans += _sum(d.front());
    else if(d.front().fr <= r) ans += _sum(P(d.front().fr,r));
    ret += _sum(d.front());
    d.pop_front();
  }
  if(!d.empty() && ret != q){
    P p = P(d.front().fr,d.front().fr + q - ret - 1);
    if(p.sc <= r) ans += _sum(P(p.fr,p.sc));
    else if(p.fr <= r) ans += _sum(P(p.fr,r));
  }
  return ans;
}
void shuffle(int* xy){
  deque< P > tmp[2];
  int ret = 0;
  for(int i = 0 ; i < 2 ; i++ ){
    while( ret + _sum(d.front()) <= xy[i]){
      tmp[i].push_back(d.front());
      ret += _sum(d.front());
      d.pop_front();
    }
    if(ret != xy[i]){
      tmp[i].push_back(P(d.front().fr,d.front().fr + xy[i] - ret - 1));
      d.front().fr = d.front().fr + xy[i] - ret;
      ret = xy[i];
    }
  }
  d.insert(d.end(),tmp[1].begin(),tmp[1].end());
  d.insert(d.end(),tmp[0].begin(),tmp[0].end()); 
}
int main(){
  while(cin >> n , n){
    cin >> m;
    d.push_back( P( 1, n));
    int p, q, r;
    cin >> p >> q >> r;
    while(m--){
      int xy[2];
      cin >> xy[0] >> xy[1];
      shuffle(xy);
    }
    cout << query(--p, q, r) << endl;
    d.clear();
  }
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x <<" "<< y << " "<< z << endl;;
}

Measured memory_bytes: 896