akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int> > v(3, vector<int>(n+1, 0));
    while(--m >= 0){
        int q, k;
        cin >> q >> k;

        if(q == 0){
            long long a = 1;
            long long b = n + 1;
            while(a < b){
                long long c = (a + b) / 2;
                if(c * (c + 1) / 2 < k)
                    a = c + 1;
                else
                    b = c;
            }
            if(a <= n)
                ++ v[q][a];
        }
        else{
            if(k <= n)
                ++ v[q][k];
        }
    }

    long long ans = 0;
    for(int i=1; i<=n; ++i){
        for(int j=1; j<3; ++j)
            v[j][i] += v[j][i-1];

        long long cnt = 1;
        for(int j=0; j<3; ++j)
            cnt *= i - v[j][i];
        ans += cnt;
    }
    cout << ans << endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

ll const mod = 1e9 + 7;

ll add(ll a, ll b)
{
	return (a + b) % mod;
}

ll sub(ll a, ll b)
{
	return (a - b + mod) % mod;
}

ll mul(ll a, ll b)
{
	return (a * b) % mod;
}

int const N = 2007;
ll dp[N];

int main()
{
	fastio;

	int n;
	cin >> n;

	dp[0] = 1;
	dp[1] = dp[2] = 0;
	ll sum = 1;

	for (int i = 3; i <= n; ++i)
	{
		dp[i] = add(dp[i], sum);
		dp[i] = sub(dp[i], dp[i-1]);
		dp[i] = sub(dp[i], dp[i-2]);

		sum = add(sum, dp[i]);
	}
	cout << dp[n] << '\n';

	return 0;
}


Measured memory_bytes: 3576
n = STDIN.gets.to_i
n.times do
  first_integer  = STDIN.gets.chomp
  second_integer = STDIN.gets.chomp
  if first_integer.length < second_integer.length then
    first_integer, second_integer = second_integer, first_integer
  end
  carry=0
  sum=""
  first_integer.chars.reverse.each_with_index do |e, i|
    tmp=0
    tmp+=carry
    tmp += e.to_i
    if second_integer.length > i then
      tmp += second_integer[-1*(i+1)].to_i
    end 
    carry=(tmp/10).to_i
    sum = (tmp-carry*10).to_s + sum
  end
  if carry > 0 then
    sum = carry.to_s + sum
  end
  if sum.length > 80 then
    puts "overflow"
  else 
    puts sum
  end
end

Measured memory_bytes: 8736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int n,cnt,a,b;
int ans1,ans2;
int read(){
    int f=1,x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int main(){
    cin>>n>>a>>b;
    if(a+b<=n) ans2=0;
    else ans2=a+b-n;
    ans1=min(a,b);
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        a: char,
    }

    let flag = a.is_lowercase();

    if flag {
        println!("a");
    } else {
        println!("A");
    }
    
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

string solve()
{
    ll x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) > abs(x - b)) {
        return "B";
    }
    return "A";
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    int h, w, d; cin>>h>>w>>d;
    int a[310][310];
    map<int, P> mp;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>a[i][j];
            mp[a[i][j]] = make_pair(i, j);
        }
    }

    int sum[100010];
    memset(sum, 0, sizeof(sum));
    for(int i=1; i<=d; i++){
        for(int j=0; i+j<=h*w; j+=d){
            if(j == 0){
                sum[i] = 0;
            }
            else{
                sum[i+j] = sum[i+j-d] + abs(mp[i+j].first - mp[i+j-d].first) + abs(mp[i+j].second - mp[i+j-d].second);
            }
        }
    }

    int q; cin>>q;
    for(int i=0; i<q; i++){
        int l, r; cin>>l>>r;
        cout << sum[r] - sum[l] << endl;
    }
}

Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	long long N, M;
	long long ans = 0;
	std::cin >> N >> M;
	int i = 0;
	while ((long long)std::pow(2, i)*N <= M) {
		i++;
	}
	std::cout << i << std::endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
tasks = []

for i in range(N):
    A, B = map(int, input().split())
    tasks.append((B, A))

tasks.sort()

ans = "Yes"
time = 0
for task in tasks:
    time += task[1]
    if time > task[0]:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 29400
#include <iostream>
#include<iomanip>
#include <iomanip>
#include <math.h>

using namespace std;

void C();
bool subC(int*, int);

int main()
{
	C();
}
void C() {
	int N; cin >> N;
	int* H = new int[N];
	for (int i = 0; i < N; i++) cin >> H[i];

	if (subC(H, N)) cout << "Yes" << endl;
	else cout << "No" << endl;

	delete[] H;
}
bool subC(int* H, int len) {
	int tempMax = 0;
	for (int i = 0; i < len - 1; i++) {
		tempMax = fmax(tempMax, H[i]);
		if (tempMax >= H[i + 1] + 2) return false;
	}
	return true;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,K;
    vector<ll> Hs;
    ll H;
    cin>>N>>K;
    rep(i,N) {cin>>H; Hs.push_back(H);}
    if (N<=K) cout<<0<<endl;
    else{
        sort(Hs.begin(),Hs.end());
        ll ans=0;
        rep(i,N-K) ans+=Hs[i];
        cout<<ans<<endl; 
    }
    return 0;
}

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

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

    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        while (a > 0 && a % 2 == 0) a /= 2, ans++;
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
  int A,B,C,K,i;
  cin >> A >> B >> C >> K;
  i=0;
  while (A>=B) {
    B*=2;
    i++;
  }
  K-=i;
  if (K>=0) {
    for (int i=0;i<K;i++) {
      C*=2;
    }
    if(C>B) {
      cout << "Yes" << endl;
    }
    if (B>=C) {
      cout << "No" << endl;
    }
  }
  if (K<0) {
    cout << "No" << endl;
  }
}

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

int main(void){
    string s;
    cin >> s;
    int a = stoi(s),b = 0;
    for(int i = 0;i < s.size();i++)b += s[i] - '0';
    if(a % b == 0)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int A, B, C;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C;

  for (int i = 1; i <= B; i++) {
    if ((A * i) % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int h, w;
    cin >> h >> w;
    string ans = "";
    rep(i,h) {
        rep(j,w) {
            string s;
            cin >> s;
            if (s == "snuke") {
                ans += j + 'A';
                ans += to_string(i+1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N, M;
    cin >> N >> M;
    int s[M];
    char c[M];
    for(int i = 0; i < M; i++){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    for(int i = 0; i < 1000; i++){
        if(to_string(i).size() == N){
            for(int j = 0; j < M; j++){
                if(to_string(i)[s[j]] != c[j]){
                    goto pass;
                }
            }
            cout << i << endl;
            return 0;
        }
    pass:;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
a,b,c,d,e,f,g = gets.split.map(&:to_i)
ans = 0
ans += b*2
ans += (a/2)*4
ans += (d/2)*4
ans += (e/2)*4
if a.odd? && d.odd? && e.odd?
    ans += 6
elsif d.odd? && e.odd? && a != 0
    ans += 2
elsif a.odd? && ((d.odd? && e != 0) || (e.odd? && d != 0))
    ans += 2
end
puts ans/2

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
  int a[100],n,d,x,i;
  scanf("%d",&n);
  scanf("%d %d",&d,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    x+=1+(d-1)/a[i];
  }
  printf("%d\n",x);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.equals("H")) {
            System.out.println(b);
        } else {
            if (b.equals("H")) {
                System.out.println("D");
            } else {
                System.out.println("H");
            }
        }
    }
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	string S, T;

	cin >> S >> T;
	cout << T << S << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long 
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/

const int N=2e5+2;
ll dp[102][N+1];

int main(){
    //IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        int n, w1;
    cin>>n>>w1;
 
    vi<int> w(n+1), v(n+1);
 
    FORE(i, 1, n) {
        cin>>w[i]>>v[i];
    }
 
    FORE(i, 1, N)
    dp[0][i] = (int) 2e9;
 
    dp[0][0] = 0;
        FORE(i,1,n){
            FORE(j,0,N){
            dp[i][j] = (int) 2e9;
                if(j == 0) {
                    dp[i][j] = 0;
                } else {
                    if(v[i] <= j and dp[i-1][j - v[i]] != (int) 2e9) {
                        dp[i][j] = min(dp[i-1][j], w[i] + dp[i-1][j - v[i]]);
                    } else {
                        dp[i][j] = dp[i-1][j];
                    }
                }
            }
        }
           ll mx = 0;
 
        FORE(i, 0, N-1) {
            if(dp[n][i] <= w1)
                mx = i;
        }
    
        cout<<mx;
    }
    return 0;
} 

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

#define lli long long int
#define endl "\n"

lli number_of_paths(int i, int j, int h, int w, vector<vector<char> > &grid, vector<vector<lli> > &dp){
	if(i == h && j == w)
		return 1;

	if(i > h || j > w)
		return 0;

	if(grid[i][j] == '#')
		return 0;

	if(dp[i][j] != -1)
		return dp[i][j];

	else{
		dp[i][j] = (number_of_paths(i+1, j, h, w, grid, dp) % 1000000007 + 
		            number_of_paths(i, j+1, h, w, grid, dp) % 1000000007) % 1000000007;

		return dp[i][j];
	}
}


int main(){
	int h, w;
	cin >> h >> w;

	vector<vector<char> > grid(h, vector<char>(w));

	for(int i = 0 ; i < h; i++){
		for(int j = 0 ; j < w ; j++){
			cin >> grid[i][j];
		}
	}

	vector<vector<lli> > dp(h, vector<lli>(w, -1));
	lli number = number_of_paths(0, 0, h-1, w-1, grid, dp);

	cout << number%1000000007 << endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	ll x;
	cin >> x;
	ll ans = 0;
	ans += x / 11 * 2;
	x %= 11;
	if(x == 0){
	}else if(x <= 6){
		ans++;
	}else{
		ans += 2;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[39];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int c;
		cin >> c;
		for (int j = 0; j < c; j++) {
			int n;
			cin >> n;
			a[n]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		if (a[i] == n) {
			ans++;
		}
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations
N, D = map(int, input().split())
X = []
for _ in range(N):
    X.append(list(map(int, input().split())))

def dist2(x, y):
    return sum((a-b)**2 for (a, b) in zip(x, y))

def judge(d):
    m = int(d ** 0.5)
    return m*m == d

cnt = 0
for p in combinations(X, 2):
    x, y = p
    cnt += 1 if judge(dist2(x, y)) else 0

print(cnt)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int a[10001];

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 == 0 || a[i] % 5 == 0) {
        continue;
      } else {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;
}

Measured memory_bytes: 3048
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		{
			Scanner stdin = new Scanner(System.in);
			List<Integer> result = new ArrayList<>();
			int i = 0, count = 0;
			while (true) {
				String[] input = stdin.nextLine().split(" ");
				int a = 0;
				int b = 0;
				char operation = 0;
				a = Integer.parseInt(input[0]);
			    operation = input[1].charAt(0);
			    b = Integer.parseInt(input[2]);
				if (operation == '?') {
					break;
				}
				switch (operation) {
				case '+':
					result.add(a + b);
					break;

				case '-':
					result.add(a - b);
					break;
				case '*':
					result.add(a * b);
					break;
				case '/':
					result.add(a / b);
					break;
				}
				count = i;
				i++;
			}
			for (int j = 0; j < result.size(); j++) {
				System.out.println(result.get(j));
			}
		}
	}
}

Measured memory_bytes: 26280
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int r, g, b;
	std::cin >> r >> g >> b;
	if ((g * 10 + b) % 4 == 0) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

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

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)5e3 + 7;
const int MAXN = (int)3e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

void solve() {
	int n; cin >> n;
	if (n % 10 == 3) {
		cout << "bon";
		return;
	}
	if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		cout << "pon";
		return;
	}
	cout << "hon";
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3644
def main():

    N = int(input())
    ans = len(str(N))
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            j = N // i
            ans = min(ans, max(len(str(i)), len(str(j))))
    print(ans)

if __name__ == "__main__":
    main()

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

    //入力部
    int n;
    vector<int> a(100);
    cin >> n;
    for(int i=0;i<n;i++)cin >> a.at(i);

    //計算部
    sort(a.begin(),a.end()); //ソート関数でソートします(今回の配列長ならバブルソートでも可)
    reverse(a.begin(),a.end());// 昇順から降順に反転
  
    int even = 0, odd = 0; //偶数、奇数それぞれの要素の総和を格納する変数を用意
    for(int i=0;i<n;i++){
        if(i%2) odd += a.at(i); // 奇数個目の要素なら
        else even += a.at(i); // 偶数個目の要素なら
    }

    //出力部
    cout << even-odd << endl;
    return 0;
}


Measured memory_bytes: 256
require 'set'

dir = { "N" => [0, 1],
        "E" => [1, 0],  
        "W" => [-1, 0],
        "S" => [0, -1]
      }.freeze

loop do
  tr = Set.new

  x = 10
  y = 10

  n = gets.to_i
  break if n == 0
  n.times do
    tr.add( gets.chomp.split.map &:to_i )
  end

  m = gets.to_i
  m.times do
    d, l = gets.split
    l.to_i.times do
      x += dir[d][0]
      y += dir[d][1]

      if tr.include?([x, y])
        tr.delete([x, y])
      end
    end
  end
   
  puts tr.empty? ? "Yes" : "No"
end

Measured memory_bytes: 6192
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    char S[N+1];

    scanf("%s", S);

    int x = 0, max = 0;

    for(int i = 0; i < N; i++){
        if(S[i] == 'I'){
            x++;
        }else{
            x--;
        }
        if(x > max){
            max = x;
        }
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0] == 'i'){ insert(key); np++; size++; }
        else if (com[0] == 'd'){
            if (strlen(com)>6){
                if (com[6]=='F') deleteFirst();
                else if (com[6]=='L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}




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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    queue<int> b;
    vector<int> c;

    int prev = -1;
    rep(i, n) {
        if(i == 0) {
            prev = a[i];
            c.push_back(a[i]);
        }
        else {
            if(prev == a[i]) {
                b.push(a[i]);
            } else {
                c.push_back(a[i]);
            }
            prev = a[i];
        }
    }

    if(b.size()%2 == 0) {
        cout << c.size() << endl;
    } else {
        cout << c.size()-1 << endl;
    }

    return 0;
}


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

# 1 75, 3 25, 5 15 

def find_primes(n):
    nums=list(range(2,n+1))
    primes = []
    while nums:
        p = nums[0]
        primes.append(p)
        for _ in range(6):
            nums = [n if n%p else n//p for n in nums]
        nums = [n for n in nums if n!=1]
    return primes
assert(find_primes(30)[9]==29)

#primes = find_primes(100)

def primes_of_factor(n):
    nums=list(range(1,n+1))
    primes = find_primes(n)
    ret = {p:0 for p in primes}
    for p in primes:
        s = sum([n%p==0 for n in nums])
        ret[p] += s
        while s:
            nums = [n//p if n%p==0 else n for n in nums]
            s = sum([n%p==0 for n in nums])
            ret[p] += s
    return ret
assert(primes_of_factor(25)[5]==6)

primes = primes_of_factor(N)

answer = len([v for v in primes.values() if v>=74])

from itertools import permutations

for P,Q in permutations(primes.items(), 2):
    if P[1]>=24 and Q[1]>=2:
        answer +=1
    if P[1]>=14 and Q[1]>=4:
        answer +=1

for P,Q,R in permutations(primes.items(), 3):
    if P[1]>=2 and Q[1]>=4 and R[1]>=4:
        if Q[0]>R[0]:
            answer +=1

print(answer)

Measured memory_bytes: 3188
count=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
for i in range(n):
    table=list(map(int, input().split()))
    tou=table[0]
    kai=table[1]
    ban=table[2]
    nin=table[3]
    if count[tou-1][kai-1][ban-1]<10:
        count[tou-1][kai-1][ban-1]+=nin
for k in range(4):
    for j in range(3):
        for i in range(10):
            print("",count[k][j][i], end="")
        print()
    if k<3:
        for l in range(20):
            print("#", end="")
        print()


Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 3e3;


void solve()
{
    string s; cin >> s;

    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        cout << 3 ;
    else if( (s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R') )
        cout << 2 ;
    else if( s[0]=='R' || s[1]=='R' || s[2]=='R')
        cout << 1 ;
    else
        cout << 0;
}
int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
    return 0;
}

Measured memory_bytes: 3640
from collections import defaultdict

s = input()
n = len(s)
mod = 2019
DP = [0 for i in range(n+2)]
DP[n+1] = 0

for i in reversed(range(n)):
    DP[i] = (DP[i+1] + int(s[i])*(pow(10,n-i-1,mod)))%mod
DP.pop(-1)

arr = defaultdict(int)
for dp in DP:
    arr[dp]+=1

ans = 0
for i in arr.values():
    ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 16720
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    int n, h, w;
    scanf("%d %d %d", &n, &h, &w);
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        if(a >= h && b >= w) ans++;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

long long int min(long long int a,long long int b){
  if(a>b) return b;
  return a;
}

int main(void){
  long long int a,b,c,tmp;
  scanf("%lld %lld %lld",&a,&b,&c);
  tmp = min(a+b,c);
  if((a+b)<c) tmp++;
  printf("%lld\n",tmp+b);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 2*acos(0.0)
#define boost ios::sync_with_stdio(false);cin.tie(0)
/*ll arr[1000000];void seive(){memset(arr,1,sizeof(arr));arr[0]=arr[1]=0;for(ll i=2;i<=(sqrt(1000000));i++){if(arr[i]){for(ll j=(i+i);j<=1000000;j+=i){arr[j]=0;}}}}*/
int main()
{
 boost;
  ll a;
  cin>>a;
  cout<<a+(a*a)+(a*a*a)<<endl;
    
    
}


Measured memory_bytes: 3628
#AIsing2020 c
 
import sys,math,collections,itertools
input = sys.stdin.readline
 
N = int(input())
ans = [0]*N
 
for x in range(1,101):
    for y in range(x+1,101):
        for z in range(y+1,101):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n <= N:
                ans[n-1] +=6
                
for x in range(1,101):
    y = x
    for z in range(1,101):
        if z == x:
            continue
        else:
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n <= N:
                ans[n-1] +=3
 
for x in range(1,101):
    y = x
    z = x
    n = x**2+y**2+z**2+x*y+y*z+z*x
    if n <= N:
        ans[n-1] +=1
        
for i in range(N):
    print(ans[i])
        

Measured memory_bytes: 69404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(D);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a) {
  int sum = 0;
  vi last(26);
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j]);
    }
  }
  return sum;
}

void solve() {
  int sum = 0, y = 0;
  for (int i = 0; i < 26; i++) {
    vi a(D, i);
    int x = simulate(a);
    if (x > sum) {
      sum = x;
      y = i;
    }
  }

  ans = vi(D, 1);
}

int main() {
  input();
  solve();
  output();
}


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

const int N = 1e5 + 5, mod = 1e9 + 7, inf = INT_MAX;

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    int ans = inf, n, x, c;
    cin >> n;
    while (n--)
    {
        c = 0;
        cin >> x;
        while (x % 2 == 0)
            c++,
            x /= 2;
        ans = min(ans, c);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int sum=0;
  sort(a.rbegin(),a.rend());
  rep(i,k)sum+=a[i];
  cout<<sum;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define int long long
using namespace std;
const int N=302;
const int mod=1e9+7;
int n,dp[2*N][2*N],damn[2*N],cnt[2*N],wow[2*N];
int dem(int l,int r){
//	if(l==n*2+1||r==0){
//		return 0;
//	}
	return r-l+1-cnt[r]+cnt[l-1];
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int i,j,num,k,l,ans=0;
	cin>>n>>num;
	for(i=1;i<=num;i++){
		cin>>j>>k;
		damn[j]=k;
		damn[k]=j;
		cnt[j]++;
		cnt[k]++;
	}
	wow[0]=1;
	for(i=2;i<=2*n;i++){
		cnt[i]+=cnt[i-1];
		wow[i]=wow[i-2]*(i-1);
		wow[i]%=mod;
	}
	bool cac=false;
	for(i=1;i<=2*n;i++){
		for(j=i+1;j<=2*n;j+=2){
			cac=false;
			for(k=i;k<=j;k++){
				if(damn[k]){
					if(damn[k]<i||damn[k]>j){
						cac=true;
						break;
					}
				}
			}
			if(cac){
				continue;
			}
			dp[i][j]=wow[dem(i,j)];
			for(k=i+1;k<j;k+=2){
				dp[i][j]-=dp[i][k]*wow[dem(k+1,j)];
				dp[i][j]%=mod;
				if(dp[i][j]<0){
					dp[i][j]+=mod;
				}
			}
			ans+=dp[i][j]*wow[dem(j+1,2*n)+dem(1,i-1)];
			ans%=mod;
//			cout<<dp[i][j]<<' '<<i<<' '<<j<<endl;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3072
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

int h,w;
string s[3000];
int tate[3000][3000];
int yoko[3000][3000];

signed main(){
  cin >> h >> w;
  REP(i,h) cin >> s[i];
  REP(i,h){
    int st = 0;
    int gl = -1;
    REP(j,w){
      if(s[i][j] == '#'){
        tate[i][j] = -INF;
        for(int k1 = st;k1 <= gl;k1++){
          tate[i][k1] = gl-st+1;
        }
        st = j+1;
      }
      if(s[i][j] == '.'){
        gl = j;
      }
    }
    for(int k1 = st;k1 <= gl;k1++){
      tate[i][k1] = gl-st+1;
    }
  }
  REP(j,w){
    int st = 0;
    int gl = -1;
    REP(i,h){
      if(s[i][j] == '#'){
        yoko[i][j] = -INF;
        for(int k1 = st;k1 <= gl;k1++){
          yoko[k1][j] = gl-st+1;
        }
        st = i+1;
      }
      if(s[i][j] == '.'){
        gl = i;
      }
    }
    for(int k1 = st;k1 <= gl;k1++){
      yoko[k1][j] = gl-st+1;
    }
  }
  int ans = -INF;
  REP(i,h){
    REP(j,w){
      ans = max(tate[i][j]+yoko[i][j],ans);
    }
  }
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 100224
sa = gets.strip.chars
sb = gets.strip.chars
sc = gets.strip.chars
h = "a"
while true
  if h == "a"
    if sa.size==0
      t = "A"
      break
    end
    h = sa[0]
    sa.shift
  elsif h == "b"
    if sb.size==0
      t = "B"
      break
    end
    h = sb[0]
    sb.shift
  else
    if sc.size==0
      t = "C"
      break
    end
    h = sc[0]
    sc.shift
  end
end
puts t

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

int main() {
  int n;
  while (cin >> n, n) {
    auto c = vector<int>(n);
    for (int i = 0; i < n; ++i) {
      string w; cin >> w;
      c[i] = w.length();
    }
    auto solve = [&]() {
      for (int i = 0; i < n; ++i) {
        auto phrase = vector<int>{5, 7, 5, 7, 7};
        int idx = 0;
        for (int j = i; j < n; ++j) {
          if (phrase[idx] > 0) phrase[idx] -= c[j];
          if (phrase[idx] < 0) break;
          if (phrase[idx] == 0) ++idx;
          if (idx == 5) return i + 1;
        }
      }
      return 0;
    };
    cout << solve() << endl;
  }
  return 0;
}



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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a;
  while(cin >> n && n){
    vary(ll,v,2*n,0);
    ll t = n,h = n;
    rep(i,n){
      cin >> a;
      --a;
      v[a] = 1;
    }
    bool f = true;
    while(1){
      rep(i,2 * n){
        if(v[i] == 1 && f){
          v[i] = -1;
          f = false;
          --h;
        }
        else if(v[i] == 0 && !f){
          v[i] = -2;
          f = true;
          --t;
        }
        if(i == 2 * n -1){
         f = !f;
        }
        if(h * t == 0) break;
      }
      if(h * t == 0) break;
    }
    cout << t <<endl << h << endl;
  }
  return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=201234;

int n,a,b;
ll f[nmax],inv[nmax],res;

ll ksm(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}

ll solve(ll a){
    ll ans=inv[a];
    for(int i=0;i<a;++i)
        ans=ans*(n-i)%MOD;
    return ans;
}

int main()
{
    scanf("%d%d%d",&n,&a,&b);
    f[0]=inv[0]=1;
    for(int i=1;i<nmax;++i)
        f[i]=f[i-1]*i%MOD;
    inv[nmax-1]=ksm(f[nmax-1],MOD-2);
    for(int i=nmax-2;i;--i)
        inv[i]=inv[i+1]*(i+1)%MOD;
    res=ksm(2,n%(MOD-1))-1;
    res=(res-solve(a)+MOD)%MOD;
    res=(res-solve(b)+MOD)%MOD;
    printf("%lld\n",res);
    return 0;
}


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

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

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

using f32 = float;
using f64 = double;

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

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

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

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

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

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

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


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

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


#define MAX_N 50
i64 N;
i64 d[MAX_N];
i64 S[MAX_N]; // 累積和

int main() {
  cin >> N;
  REP(i, N) cin >> d[i];

  i64 s = 0;
  REP(i, N) {
    s += d[i];
    S[i] = s;
  }

  s = 0;
  REP(i, N) {
    s += d[i] * (S[N - 1] - S[i]);
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    h-=a[i];
  }
  if(h<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

typedef long long llint;

const int MAXN = 100100;

llint arr[MAXN];
llint sum[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, i;
	
	cin>>n;
	
	for (i = 0; i < n; ++i)
		cin>>arr[i];
	
	sort(arr, arr + n);
	
	for (i = 0; i < n; ++i)
		sum[i + 1] = sum[i] + arr[i];
	
	for (i = n - 1; arr[i] <= 2 * sum[i]; --i);
	
	cout<<n - i<<'\n';
}


Measured memory_bytes: 1792
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe\n";
    } else {
        cout << "safe\n";
    }

    return 0;
}

Measured memory_bytes: 3652
S=input()
T=input()
N=len(S)

S_charmap={ chr(i):-1 for i in range (97,97+26)}
T_charmap={ chr(i):-1 for i in range (97,97+26)}
S_kinds=0
T_kinds=0

ans='Yes'
for i in range(N):
	if S_charmap[S[i]] == -1:
		S_kinds += 1
		S_charmap[S[i]] = S_kinds
	if T_charmap[T[i]] == -1:
		T_kinds += 1
		T_charmap[T[i]] = T_kinds
	if S_charmap[S[i]] == T_charmap[T[i]]:
		continue
	else:
		ans='No'
		break
print(ans)

Measured memory_bytes: 3632