akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 2e5 + 10;

typedef vector<vector<ll> > mtrx;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}


int a[111111];
int ans[111][111];

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int cury = 0, curx = 0, d = +1;
	for (int c = 1; c <= n; c++) {
		while (a[c]) {
			ans[curx][cury] = c;
			a[c]--;
			curx+=d;
			if (curx == h || curx == -1) {
				if (d == 1) d = -1;
				else d = 1;
				curx += d, cury++;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
H_list=[]
W_list=[]
while True:
  H,W = map(int, input().split())
  if H == 0 and W == 0: 
    break
  H_list.append(H)
  W_list.append(W)
  
for (Hlist, Wlist) in zip(H_list,W_list):
  for i in range(Hlist):
    for j in range(Wlist):
        if i==0 or j==0 or i==Hlist-1 or j==Wlist-1: 
            print("#", end="")
        else:
            print(".", end="")
    print()
  print()


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

signed main() {
  int N; cin >> N;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
    p[i]--;
  }
  
  int ans = 0;

  rep(i, N) {
    if(p[i] == i) {
      swap(p[i], p[i+1]);
      ans++;
    }
  }

  cout << ans << endl;
  

}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  VLL _a(n), _b(n);
  rep(i,n) cin >> _a[i];
  rep(i,n) cin >> _b[i];

  VLL a(n), b(n);
  ll ans = 0;
  // aを固定して考えたときに a[i] + b[j] の kbit 目が立っているbの条件を探し、
  // 条件を満たすbの数をカウント
  rep(k,30){
    ll T = 1LL<<k;

    rep(i,n) {
      a[i] = _a[i] % (2LL*T);
      b[i] = _b[i] % (2LL*T);
    }
    sort(all(b));
    ll cnt = 0;
    rep(i,n){
      // 条件1: 2^k <= ai + bj < 2^(k+1)
      //    ->  2^k - a[i] <= b[j] < 2^(k+1) - a[i]
      //    ->  T - a[i] <= b[j] < 2*T - a[i]
      cnt += lower_bound(all(b), 2LL*T - a[i]) - lower_bound(all(b), T - a[i]) ;
      // 条件2: 2^k + 2^(k+1) <= ai + bj < 2 * 2^(k+1)
      //    ->  2^k + 2^(k+1) - a[i] <= b[j] < 2 * 2^(k+1) - a[i]
      //    ->  3 * T - a[i] <= b[j] < 4 * T - a[i]
      cnt += lower_bound(all(b), 4LL*T - a[i]) - lower_bound(all(b), 3LL*T - a[i]) ;

    }
    if(cnt % 2 == 1) ans |= (1LL<<k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8576
N=int(input())
A = [int(i) for i in input().split()]

if 0 in A:
    multiple = 0
else:
    multiple = 1
    for i in range(N):
        multiple = multiple * A[i]
        if multiple > 1000000000000000000:
            multiple = -1
            break

print(multiple)

Measured memory_bytes: 21632
#include<cstdio>

int main(void)
{
	int m,d;
	scanf("%d%d",&m,&d);
	int ans=0;
	for(int i=1; i<=m; ++i)
	{
		for(int j=20; j<=d; ++j)
		{
			if(j%10 < 2) continue;
			if((j/10)*(j%10) == i) ++ans;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(void){
  int max=0,c,n,p;

  std::cin >> n;
  std::cin >> p;
  c=0;
  for(int i=1;i<n;i++){
    int v;
    std::cin >> v;
    if(p>=v){
      c++;
    }else{
      if(max < c){
	max = c;
      }
      c=0;
    }
    p=v;
  }
  if(max < c){
    max = c;
  }

  std::cout << max;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <queue>
#include <algorithm>
#define INF (1<<27)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> _P; //point chicket
typedef pair<int,_P> P; //cost _P
struct Edge {
	int to,cost;
	Edge(int _to,int _cost) {to=_to,cost=_cost;}
};
int dist[11][100];
vector<Edge> edges[100];
int main() {
	int c,n,m,s,d;
	while(scanf("%d %d %d %d %d",&c,&n,&m,&s,&d),c) {
		rep(i,n) edges[i].clear();
		rep(i,c+1) rep(j,n) dist[i][j]=INF;
		rep(i,m) {
			int a,b,f;
			scanf("%d %d %d",&a,&b,&f);
			edges[a-1].push_back(Edge(b-1,f));
			edges[b-1].push_back(Edge(a-1,f));
		}
		priority_queue<P,vector<P>,greater<P> > Q;
		Q.push(P(0,_P(s-1,c)));
		dist[c][s-1]=0;
		while(!Q.empty()) {
			P p=Q.top(); Q.pop();
			_P _p=p.second;
			if(dist[_p.second][_p.first]<p.first) continue;
			rep(i,edges[_p.first].size()) {
				if(dist[_p.second][edges[_p.first][i].to]>(p.first+edges[_p.first][i].cost)) {
					dist[_p.second][edges[_p.first][i].to]=(p.first+edges[_p.first][i].cost);
					Q.push(P(p.first+edges[_p.first][i].cost,_P(edges[_p.first][i].to,_p.second)));
				}
				if(_p.second>0&&(dist[_p.second-1][edges[_p.first][i].to]>(p.first+edges[_p.first][i].cost/2))) {
					dist[_p.second-1][edges[_p.first][i].to]=(p.first+edges[_p.first][i].cost/2);
					Q.push(P(p.first+edges[_p.first][i].cost/2,_P(edges[_p.first][i].to,_p.second-1)));
				}
			}
		}
		int sum=1<<30;
		rep(i,c+1)if(sum>dist[i][d-1])sum=dist[i][d-1];
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1072
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		long N = Long.parseLong(W);
		String A = in.readLine();
		String B = in.readLine();
		String C = in.readLine();

		long ans = 0;
		for(int i=0;i<N;i++){
			if(A.charAt(i)==B.charAt(i) && A.charAt(i)==C.charAt(i)){

			}else if(A.charAt(i)==B.charAt(i) || A.charAt(i)==C.charAt(i) ||B.charAt(i)==C.charAt(i)){
				ans++;
			}else{
				ans+=2;
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++) {
        ll mini = 1000000000;
        for(ll j=1;j<=k;j++) {
            ll temp=1000000000;
            if(i>=j) {
                temp = dp[i-j]+abs(arr[i-j]-arr[i]);
                if(temp<mini)
                    mini = temp;
            }
        }
        dp[i] = mini;
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
/*
  AOJ 1121
  Title:Kanglish:Analysis on Artificial Language
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int occur[39][39];
char combi[12][3]={"ld","mb","mp","nc","nd","ng","nt","nw","ps","qu","cw","ts"};
int n;
char buf[1001];

void code2k(char *s,int code)
{
  if(code == 0)
    {
      s[0]=' ';
      s[1]='\0';
    }
  else if(code<=26)
    {
      s[0]='a'-1+code;
      s[1]='\0';
    }
  else
    strcpy(s,&combi[code-27][0]);
}
int k2code(char *s)
{
  int i;

  if(*s=='\0'||*s==' ')
    return(0);
  for(i=0;i<12;i++)
    if(0==strncmp(s,&combi[i][0],2))
      return(27+i);
  return(*s-'a'+1);
}
void analize(char *s)
{
  int c,pc;

  pc=k2code(s);
  while(*s)
    {

      if(pc>26)
	s+=2;
      else
	s++;

      c=k2code(s);

      if(pc>0 && c>0)
	occur[pc][c]++;
      pc=c;
    }
}
void print_result()
{
  int i,j,max_,max_c;;
  char s1[3],s2[3];

  for(i=1;i<=38;i++)
    {
      max_=0;
      max_c=1;
      for(j=1;j<=38;j++)
	if(occur[i][j]>max_)
	  {
	    max_=occur[i][j];
	    max_c =j;
	  }
      code2k(s1,i);
      code2k(s2,max_c);
      printf("%s %s %d\n",s1,s2,max_);
    }
}
main()
{
  int i;
 
  scanf("%d",&n);
  fgets(buf,1000,stdin);
  for(i=0;i<n;i++)
    {
      fgets(buf,1000,stdin);
      analize(buf);
    }
  print_result();
  return(0);

}

Measured memory_bytes: 628
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=0;
int b=sc.nextInt();
 String []c=String.valueOf(b).split("");
for(int i=0;i<c.length;i++){
    if(c[i].equals("7")){
        a=1;
        i=3;
    }
}
if(a==1){
    System.out.println("Yes");
}else{
       System.out.println("No"); 
}
}
}

Measured memory_bytes: 27056
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=100;
int main()
{
	int n;
	scanf("%d",&n);
	if(n%1000==0)
	{
		printf("0\n");
	}
	else
	{
		printf("%d\n",1000-n%1000);
	}
	return 0;
}


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

int main()
{
	int res = 0;
	char c1, c2;
	cin >> c1;
	while (cin >> c2) {
		if (c1 != c2) {
			res++;
			c1 = c2;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=1000000007,N=100000;
const double pi=acos(-1.0);
typedef long long ll;

int read()
{
	int x=0,f=1;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 x*f;
}

int main()
{
	ll k=read(),a=read(),b=read();
	ll ans=k+1;
	if (a>=b) {cout << k+1;return 0;}
	if (k+1<=a) {cout << k+1;return 0;}
	ll now=a;k-=(a-1);
	ll tim=k/2;now+=tim*(b-a);
	if (k%2) now++;
	ans=max(ans,now);
	cout << ans;
	return 0;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

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;
}

int n;
vi a, sum;

void solve() {
  cin >> n;
  rep(i, 0, n) {
    int A;
    cin >> A;
    a.pb(A);
    if (i == 0) {
      sum.pb(A);
      continue;
    } else {
      sum.pb(sum[i - 1] + A);
    }
  }

  int res = 1LL << 60;
  for (int i = 2; i <= n - 2; i++) {  // i番目の切れ目で切る
    int low = 0, high = i - 1;
    while (high - low > 1) {
      int mid = (high + low) / 2;
      if (sum[mid] >= sum[i - 1] - sum[mid]) {
        high = mid;
      } else {
        low = mid;
      }
    }
    int P = sum[low], Q = sum[i - 1] - sum[low];
    int P2 = sum[high], Q2 = sum[i - 1] - sum[high];
    int left_min = min(P, Q), left_max = max(P, Q);
    if (abs(P2 - Q2) < abs(P - Q)) {
      left_min = min(P2, Q2);
      left_max = max(P2, Q2);
    }

    low = i, high = n - 1;
    while (high - low > 1) {
      int mid = (high + low) / 2;
      if (sum[mid] - sum[i - 1] >= sum[n - 1] - sum[mid]) {
        high = mid;
      } else {
        low = mid;
      }
    }
    int R = sum[low] - sum[i - 1],T = sum[n - 1] - sum[low];
    int R2 = sum[high] - sum[i - 1], T2 = sum[n - 1] - sum[high];
    int right_min = min(R, T), right_max = max(R, T);
    if (abs(R - T) > abs(R2 - T2)) {
      right_min = min(R2, T2);
      right_max = max(R2, T2);
    }

    int tmp = max(left_max, right_max) - min(left_min, right_min);
    res = min(res, tmp);
  }
  cout << res << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 3564
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>>G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    stack<ll> look;
    vector<ll>dist(n, -1);
    ll ans = 0;
    look.push(0);
    rep(i, n) {
        if (dist[i] != -1)continue;
        dist[i] = 1;
        ll member = 1;
        look.push(i);
        while (!look.empty()) {
            ll now = look.top();
            look.pop();
            for (ll next : G[now]) {
                if (dist[next] != -1)continue;
                member++;
                dist[next] = member;
                look.push(next);
            }
        }
        ans = max(ans, member);
    }
    
    cout << ans;
}

/*
*/


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

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

int main(){

    ll a , b;
    cin >> a >> b;
    cout << a*b << endl;


    return 0;
}

Measured memory_bytes: 3632
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  string s;
  cin >> s;
  bool valid = true;
  valid &= s.size() >= 6;
  valid &= any_of(all(s), ::isdigit);
  valid &= any_of(all(s), ::islower);
  valid &= any_of(all(s), ::isupper);
  cout << (valid ? "VALID" : "INVALID") << endl;
}

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

int main() {
  int N;
  cin >> N;
  int a[N],b[N];
  int i;
  int s = 1;
  
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = 0;
  }
  b[0] =1;
  
  for(i=0;i<N;i++){
    s = a[s-1];
    if (s==2) break; 
  }
  
  if (i == N) i = -2;
  cout << i+1;
  
  return 0;
}

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

using namespace std;

typedef long long ll;

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

int main()
{
  int N; scanf("%d", &N);
  ll ans = 1;
  for (int i = 2; i <= N; ++i) {
    ans = (ans * i) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import math
inData = [float(i) for i in input().split()]
a = inData[0]
b = inData[1]
C = math.radians(inData[2])
S = a * b * math.sin(C) / 2
c = pow(a**2 + b**2 - 2 * a * b * math.cos(C),1/2)
L = a + b + c
h = 2 * S /a
print(S)
print(L)
print(h)


Measured memory_bytes: 5708
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  ll sum = 0;
  int n = s.size();
  rep(i, n){
    int x = s[i] - '0';
    sum += x;
  }

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


Measured memory_bytes: 3692
#include<stdio.h>
int gcd(int a, int b)
{
    int r = a % b;
    while (r > 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int i;
    int a[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int max = 0;
    for (i = 0; i < n; i++)
        if (max < a[i])
            max = a[i];
    if (k > max)
    {
        printf("IMPOSSIBLE\n");
        return 0;
    }
    int g = a[0];
    for (i = 0; i < n; i++)
        g = gcd(g, a[i]);
    if (k%g == 0)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}

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

using namespace std;

int main(){
    int64_t n,ans = 0;
    cin >> n;
    vector<int> l(n);
    for(int i = 0;i < n;i++)cin >> l[i];
    sort(l.begin(),l.end());
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            for(int k = j+1;k < n;k++){
                if(abs(l[i]-l[j]) < l[k] && l[k] < l[i]+l[j])ans++;
                else break;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
const long mod=1e9+7;
int main(){
	int a;string s;cin>>a>>s;
	if(a>=3200) cout<<s<<endl;
	else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
int main()
{
   int h,w;
   cin>>h>>w;
   vector<vector<char>>v(h,vector<char>(w,'.'));

   for(int i=0;i<h;i++)
   {
       for(int j=0;j<w;j++)
       {
           char c;
           cin>>c;
           if(c=='#')
           {
             v[i][j] = c;
           }
       }
   }
   vector<vector<int>>dp(h,vector<int>(w,0));
   for(int i=0;i<h;i++)
   {
       for(int j=0;j<w;j++)
       {
           if(i==0 && j==0)
           {
               dp[i][j]=1;
           }
           else if(i==0)
           {
               if(v[i][j]=='#')
               {
                   dp[i][j]=0;
               }
               else
               {
                   dp[i][j] = dp[i][j-1]; 
               }
           }
           else if(j==0)
           {
               if(v[i][j]== '#')
               {
                   dp[i][j]=0;
               }
               else
               {
                   dp[i][j] = dp[i-1][j]; 
               }
           }
           else
           {
                if(v[i][j]=='#')
               {
                   dp[i][j]=0;
               }
               else
               {
                   dp[i][j] = dp[i-1][j] + dp[i][j-1];
               }
           }
           dp[i][j] = (dp[i][j])%mod;
       }
   }
   cout<<(dp[h-1][w-1])%mod<<endl;
}

Measured memory_bytes: 8536
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void fast()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}
int main()
{
    fast();
    int n,cnt=0;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
        if(a[i]==cnt+1)cnt++;
    if(cnt)cout<<n-cnt;else cout<<-1;
    return 0;

}


Measured memory_bytes: 1024
require 'set'

def main
    s = gets.chomp

    (0..(s.size+1)/2-1).each do |i|
        if s[i*2,2] != "hi"
            puts "No"
            return
        end
    end
    puts "Yes"
end

main

## イディオムなど
# until s.empty? do
#
## 配列のインデックス
# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
#
## 全探索
# [0, 1].repeated_permutation(n) do |combination| # bit全探索
# array.combination(i) do |selected| # array から要素が i 個である部分列を全部抽出
#
## 無向グラフの幅優先探索(BFS)
# to = Array.new(n).map{Array.new()} # ある頂点と繋がる頂点のリスト
# m.times do
#     a,b = gets.chomp.split(" ").map(&:to_i)
#     to[a].push b
#     to[b].push a
# end
# q = Queue.new # BFS は queue
# ds = Array.new(n, -1)
# pre = Array.new(n, -1)
#
## その他
# a1 = Marshal.load(Marshal.dump(a2)) # 深いコピー
# matrix = Array.new(n).map{Array.new()} # 二次元配列の初期化
# 

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	char s[11]={},t[12]={};
	cin>>s;
	cin>>t;
	int a=strlen(s);
	for(int i=0;i<a;i++){
		if(s[i]!=t[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>


int keisan(int A[], int n, int key)
{
	int i = 0; 
	 A[n] = key;
	 while (A[i] !=key)
	 {
		 i++;
	 }
	 return i != n;
}

int main(void)
{
	int i, n, A[10000 + 1], q, key, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &key);
		{
			if (keisan(A, n, key))
			{
				sum++;
			}
		}
	}
	
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,d;
	cin >> n >> d;
	d = d*2+1;
	ll ans = (n+d-1)/d;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD 1e9+7

int main(){
	int N;
	int M = -1;
	int ans = 0;
	cin >> N;
	int i = 0;
	while(i < N){
		int H;
		cin >> H;
		if(H >= M) ans++;
		M = max(M, H);
		i++;
	}
	cout << ans << endl;
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<string> A(N), B(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	bool res = false;
	for (int i = 0; i + M <= N; i++) {
		for (int j = 0; j + M <= N; j++) {
			bool f = true;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (B[k][l] != A[i + k][j + l]) {
						f = false;
					}
				}
			}
			if (f) {
				res = true;
			}
		}
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

int main() {
    int n, a, b;

    cin>>n>>a>>b;

    int sum=0;
    int digit_sum;
    int m;
    for (int i = 0; i <= n; i++) {
        m=i;
        digit_sum=0;
        while(m>0){
            digit_sum+=m%10;
            m-=m%10;
            m/=10;
        }

        if (a<=digit_sum&&digit_sum<=b){
            sum+=i;
        }
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
N = list(map(int, input().split()))
A = list(map(int, input().split()))

g = sum(A)/(4*N[1])
cnt = 0

for i in range(N[0]):
  if A[i] >= g:
    cnt += 1

if cnt >= N[1]:
  print('Yes')
  sys.exit()

print('No')

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

int main() {
	string str;
	long long int K, i;
	
	cin >> str >> K;


	for (i = 0;i <= (int)str.size() && str[i] == '1';i++);

	//std::cout << "i:" << i << endl;

	if (i >= K) {
		std::cout << '1' << endl;
	}
	else{
		std::cout << str[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
x = [i for i in map(int, input().split())]
i = 0
min_time =5e8
while i < N-K+1:
    if x[i]<0 and x[i+K-1]<0:
        time = -x[i]
    if x[i]<0 and x[i+K-1]>=0:
        time1 = -2*x[i] + x[i+K-1]
        time2 = -x[i] + 2*x[i+K-1]
        if time1< time2:
            time = time1
        else:
            time = time2
    if x[i] >= 0 and x[i+K-1] >=0:
        time = x[i+K-1]
    if time < min_time:
        min_time = time
    i += 1
print(min_time)


Measured memory_bytes: 14480
N = int(input())
S = input()

ans = 0
f = 0
for i in S:
  if i == "A":
    f = 1
  elif f == 1 and i == "B":
    f = 2
  elif f == 2 and i == "C":
    ans += 1
    f = 0
  else:
    f = 0

print(ans)

Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		s, t := scanInt()-1, scanInt()-1
		g[s] = append(g[s], t)
	}

	memo := make([]float64, n)
	var p int
	var dfs func(v int) float64
	dfs = func(v int) float64 {
		if v == n-1 {
			return 0
		}

		t := 0.0
		for _, nv := range g[v] {
			if memo[nv] == 0 {
				memo[nv] = dfs(nv)
			}
			if p == v {
				t = math.Max(memo[nv], t)
			}
			memo[v] += memo[nv]
		}

		e := len(g[v])
		if p == v {
			memo[v] -= t
			e--
		}

		memo[v] /= float64(e)
		memo[v]++

		return memo[v]
	}

	ans := math.MaxFloat64
	for p = 0; p < n; p++ {
		if len(g[p]) == 1 {
			continue
		}
		for i := 0; i < p+1; i++ {
			memo[i] = 0
		}
		t := dfs(0)
		ans = math.Min(ans, t)
	}

	fmt.Fprintln(wr, ans)

}


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

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; 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 printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string & str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int l, r, d;
	scanf("%d%d%d", &l, &r, &d);
	int ans = 0;
	for (; l <= r; ++l)if (l % d == 0)++ans;
	printf("%d\n", ans);

	Please AC;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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


int main() {

more:;
  int n, q; cin >> n >> q;
  if (!n && !q) return 0;

  vector<tuple<int, int, string>> memo;

  rep (i, n) {
    string s; int b, c; cin >> s >> b >> c;
    memo.push_back(make_tuple(c - b + 1, c, s));
  }
  sort(all(memo));

  rep (i, q) {
    int m; cin >> m;
    bool f = true;
    for (auto&pr : memo) {
      if (get<0>(pr) <= m && m <= get<1>(pr)) {
        cout << get<2>(pr) << ' '
          << (m - get<0>(pr) + 1)
          <<endl;
        f = false;
        break;
      }
    }
    if (f) cout << "Unknown" << endl;
  }

  goto more;
}

Measured memory_bytes: 1288
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		char[] C = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			C[i] = s.charAt(i);
			}
		for (int i = 0; i < s.length(); i++) {
			if (C[i] == '1') {
				c.add('1');
			}
			if (C[i] == '0') {
				c.add('0');
			}
			if (C[i] == 'B' && c.size()>0) {
				c.remove(c.size()-1);
			}
		}
		for (int i = 0; i < c.size(); i++) {
			System.out.print(c.get(i));
		}
	}
}



Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main()
{
    long long int N,T,X=0;
    int i;
    int f[300000];
    cin>>N>>T;
    for(i=0; i<N; i++)
    {
        cin>>f[i];
    }
    if(N==1)
    {
        cout<<T<<endl;
    }
    else
    {
        for(i=1; i<N; i++)
        {
            if((f[i]-f[i-1])>=T)
            {
                X=X+T;
            }
            else
            {
                X=X+(f[i]-f[i-1]);
            }
        }
        X=X+T;
        cout<<X<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m = LI()
    a = 100 * (n - m ) + 1900 * m
    print(a * (1 << m))

main()



Measured memory_bytes: 5460
package main

import "fmt"

func getMax(nums ...int) (max int){
  max = nums[0]
  for i:=0; i<len(nums); i++{
    if nums[i] > max {
      max = nums[i]
    }
  }
  return
}

func main(){
  var a, b int
  fmt.Scan(&a, &b)
  fmt.Println(getMax(a + b, a * b, a - b))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int aa[18+2],bb[18+2],dp[18+2][2][(1<<18)+2],n,pre[18+2][(1<<18)+2];
inline int dfs(int last,int f,int msk)
{
  if(msk==(1<<n)-1)return 0;
  if(dp[last][f][msk]!=-1)return dp[last][f][msk];
  int l=aa[last];if(f)l=bb[last];
  int ret=inf;int cnt=__builtin_popcount(msk);
  for(int i=0;i<n;i++)
  {
    if(msk&(1<<i))continue;
    int p=pre[i][msk]+i;//current position of i

    int fl=(pre[i][msk]+p-cnt)%2;
    int now=aa[i];if(fl)now=bb[i];
    if(now>=l)ret=min(ret,p-cnt+dfs(i,fl,msk|(1<<i)));
  }
  return dp[last][f][msk]=ret;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  cin>>n;
  for(int i=0;i<n;i++)cin>>aa[i];
  for(int i=0;i<n;i++)cin>>bb[i];

  //for(int i=0;i<n;i++)aa[i]=1+rand()%50;
  //for(int i=0;i<n;i++)bb[i]=1+rand()%50;

  for(int i=0;i<n;i++)
  {
    for(int msk=0;msk<(1<<n);msk++)
    {
      int cnt=0;
      if(msk&(1<<i))continue;
      for(int j=i+1;j<n;j++)
        cnt+=(bool)(msk&(1<<j));

      pre[i][msk]=cnt;
    }
  }
  //cout<<pre[0][14]<<endl;
  memset(dp,-1,sizeof(dp));
  int mn=dfs(0,0,(1<<0));
  for(int i=1;i<n;i++)
    mn=min(mn,i+dfs(i,i%2,(1<<i)));
  if(mn==inf)mn=-1;
  cout<<mn<<endl;

  return 0;
}

Measured memory_bytes: 59648
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,s;
	cin>>n;
	s=n%10;
	switch(s){
		case 0:
			cout<<"pon";
			break;
		case 1:
			cout<<"pon";
			break;
		case 2:
			cout<<"hon";
			break;
		case 3:
			cout<<"bon";
			break;
		case 4:
			cout<<"hon";
			break;
		case 5:
			cout<<"hon";
			break;
		case 6:
			cout<<"pon";
			break;
		case 7:
			cout<<"hon";
			break;
		case 8:
			cout<<"pon";
			break;
		case 9:
			cout<<"hon";
			break;
	} 
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    vector<int> deg(N);
    rep(i,0,N-1){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
        ++deg[a];
        ++deg[b];
    }

    vector<bool> used(N);
    queue<int> que;
    rep(i,0,N) if(deg[i]==1) que.push(i);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        if(used[u]) continue;
        used[u]=true;
        int v=-1;
        for(int v_:graph[u]) if(!used[v_]){
            v=v_;
            break;
        }
        if(v==-1){
            cout << "First" << endl;
            return;
        }
        used[v]=true;
        for(int w:graph[v]){
            --deg[w];
            if(deg[w]==1) que.push(w);
        }
    }
    cout << "Second" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

int main(){
  int N; cin >> N;
  vector<float> A(N);
  for(int i =0; i < N; i++){
    cin >> A[i];
  }
  float rev = 0;
  for(int i=0; i<N; i++){
    rev = rev + 1/A[i];
  }
  std::cout << std::setprecision(10) << 1/rev << endl;
  

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n,i,k,kotae=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  k=a[n/2];
  for(i=0;i<n;i++){
    kotae+=abs(a[i]-k);
  }
  cout<<kotae;
}


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

unsigned int yaku( unsigned int x, unsigned int y ){
	while( x != y ){
		if( x > y )			x -= y;
		else if( x < y )	y -= x;
	}
	return x;
}

unsigned int bai( unsigned int x, unsigned int y ){
	unsigned int x0=x, y0=y;
	while( x != y ){
		if( x > y )			y += y0;
		else if( x < y )	x += x0;
	}
	return x;
}

int main(){
	unsigned int a, b;
	string line;
	while(1){
		getline( cin, line );
		sscanf( line.c_str(), "%d %d", &a, &b );
		if( line.size() == 0 ){
			break;
		}

		unsigned int max = yaku( a, b );
		unsigned int min = bai( a, b );
		cout << max << " " << min << endl;
	}
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    int N;
    cin >> N;
    vector<string> s;
    int a = 0, b = 0, majic = 0;
    int ans = 0;
    rep(i, N)
    {
        string S;
        cin >> S;
        for (int i = 1; i < S.length(); i++)
        {
            if (S[i] == 'B' && S[i - 1] == 'A')
            {
                ans++;
            }
        }
        s.push_back(S);
    }

    rep(i, N)
    {
        if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')
        {
            majic++;
        }
        else if (s[i][0] == 'B')
        {
            b++;
        }
        else if (s[i][s[i].length() - 1] == 'A')
        {
            a++;
        }
    }
    if (a > 0 && majic > 0)
    {
        a--;
        ans++;
    }
    if (b > 0 && majic > 0)
    {
        b--;
        ans++;
    }
    if(majic > 0){
    ans += majic - 1;
    }
    ans += min(a, b);
    cout << ans << endl;
}


Measured memory_bytes: 768
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 2e6 + 10;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }

int n, m;
int x[maxn], y[maxn];
int num[maxn], vis[maxn];

void solve()
{
	sa(n), sa(m);
	repp(i, 1, m)
	{
		sa(x[i]), sa(y[i]);
	}
	repp(i, 1, n)
	{
		num[i] = 1;
	}
	vis[1] = 1;
	repp(i, 1, m)
	{
		int s = x[i];
		int e = y[i];

		num[s]--;
		num[e]++;
		if (vis[s])
		{
			vis[e] = 1;
		}
		if (num[s] == 0)
		{
			if (vis[s])
			{
				vis[s] = 0;
			}
		}
	}
	int res = 0;
	repp(i, 1, n)
	{
		if (vis[i])
		{
			res++;
		}
	}
	printf("%d\n", res);
}


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


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;


typedef int64_t ll;

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	map<int, map<int, ll>>V;
	for (int i = 0; i < m; i++) {
		int tl,tr,td;
		cin >> tl >> tr >> td;
		V[tl][tr] = td;
		V[tr][tl] = -td;
	}
	vector<ll> points(n+1);
	vector<bool> det(n+1,false);

	for (auto t : V) {
		for(auto s : t.second) {
			stack<pair<int,ll>> st;
			st.push({s.first, points[t.first] + s.second});
			while(st.size()) {
				auto cu = st.top();
				st.pop();
				auto p = cu.first;
				auto pos = cu.second;
				if(det[p]){
					if(points[p] != pos){
						cout << "No\n";
						return 0;
					}
				}
				else {
					points[p] = pos;
					det[p] = true;
					for(auto k : V[p])
						st.push({k.first, pos + k.second});
				}
			}
		}
	}
	cout << "Yes\n";
}


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

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

    int res = 0;
    for (int i = 2; i <= N; i++)
    {
        if(i%2==0) continue;
        int count = 0;
        for (int j = 1; j <= i; j=j+2)
        {
            if(i % j == 0){
                count++;
            }
        }
        if(count == 8){
            res++;
        }
    }
    cout << res << endl;
    
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    int n,m;cin >>n>>m;
    vector<int>p(m);
    vector<int>y(m);
    for (int i = 0; i < m; ++i) {
        cin >>p[i]>>y[i];
        p[i]--;
    }
    vector<vector<int>>val(n);//p[i]ごとのy[i]をまとめる
    for (int j = 0; j < m; ++j) {
        val[p[j]].push_back(y[j]);
    }
    for (int v = 0; v < n; ++v) {
        sort(all(val[v]));
       // val[v].erase(unique(all(val[v])),val[v].end());
        //今回は不要　ダブりをなくす
    }
    for (int i = 0; i < m; ++i) {
        int v=p[i];
        printf("%06d",v+1);
        int id=lower_bound(all(val[v]),y[i])-val[v].begin();
        printf("%06d\n",id+1);
    }
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define MAX 234
using namespace std;

int N;
char str[MAX];
int color[MAX];
int graph[MAX][MAX];
int parent[MAX];
int depth[2][MAX];

void bfs(int cur, int idx)
{
	queue<int> q;
	q.push(cur);
	color[cur] = 0;
	depth[idx][cur] = 0;
	while (!q.empty())
	{
		cur = q.front();
		q.pop();
		for (int i = 0; i < N; i++)
		{
			if (graph[cur][i])
			{
				if (color[i] == color[cur])
				{
					cout << -1 << endl;
					exit(0);
				}
				if (color[i] < 0)
				{
					q.push(i);
					color[i] = !color[cur];
					depth[idx][i] = depth[idx][cur] + 1;
				}
			}
		}
	}
}

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> str;
		for (int j = 0; j < N; j++) graph[i][j] = str[j] - '0';
	}
	// check if binary graph
	for (int i = 0; i < N; i++)
	{
		parent[i] = -1;
		depth[0][i] = -1;
		color[i] = -1;
	}
	bfs(0, 0);
	int realMax = -1;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			depth[1][j] = -1;
			color[j] = -1;
		}
		bfs(i, 1);
		int mmax = -1;
		for (int j = 0; j < N; j++) mmax = max(mmax, depth[1][j]);
		realMax = max(mmax, realMax);
	}
	cout << realMax + 1 << endl;
	return 0;
}


Measured memory_bytes: 384
import math

a,b,x = map(int,input().split())

h=x/(a*a)
if h>(b/2):
    c=(b-h)*2
    ans = math.atan2(c,a)
else:
    d=2*a*h/b
    ans=math.atan2(b,d)
print(math.degrees(ans))

Measured memory_bytes: 38512
#include<stdio.h>
int main()
{
	double w,h,x,y;
	while(~scanf("%lf%lf%lf%lf",&w,&h,&x,&y))
  {
	double s;
	int z;
	s=w*h*0.5;
    double m,n;
	m=w*0.5;
	n=h*0.5;
	if(m==x&&n==y)
	z=1;
	else z=0;
	printf("%lf %d\n",s,z);
  } 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi a(n);
		int s=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			s+=a[i];
		}
		int res=0;
		for(int i=0;i<n;i++) if(n*a[i]<=s) res++;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3132
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

ans = 'No'
flag = False
for i in range(N-2):
  if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]: flag = True
  if flag:
    ans = 'Yes'
    break
    
print(ans)

Measured memory_bytes: 9220
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int X = scan.nextInt();
        long ans = X/500 *1000 + X%500/5 *5;
        os.println(ans);
    }


}

Measured memory_bytes: 21716