akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define REP(i,x,y) for (int i=x;i<y;i++)

const int8_t INFC=0x3f;
const int16_t INFS=0x3f3f;
const int32_t INF=0x3f3f3f3f;
const int64_t INFL=0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ios::sync_with_stdio(0);
    int n;
    string s;
    cin >> n >> s;
    int cnt=0;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='R') cnt++;
        if (s[i]=='B') cnt--;
    }
    if (cnt>0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int gcd(int a,int b){

	if(a%b == 0)return b;
	
	int t=a;
	a=b;
	b=t%b;
	
	return gcd(a,b);
	
}

int main(){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a < b)
		printf("%d\n",gcd(b,a));
	else 
		printf("%d\n",gcd(a,b));
	
	return 0;
	
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a, b;
  cin >> a >> b;
  if (b == 1) {
    cout << 0;
    return 0;
  }
  int outlet = 1;
  for (int i = 1;; i++) {
    outlet--;
    outlet += a;
    if (outlet >= b) {
      cout << i;
      return 0;
    }
  }
}

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

int main(){
  int n;
  cin >> n;
 int arr[n][3];
 for(int i=0;i<n;i++){
   for(int j=0;j<3;j++){
   	cin >> arr[i][j];
   }
}
  for(int i=1;i<n;i++){
  	for(int j=0;j<3;j++){
  		if(j==0)
  			arr[i][j] += max(arr[i-1][1],arr[i-1][2]);
  		else if(j==1)
  				arr[i][j] += max(arr[i-1][0],arr[i-1][2]);
  		else if(j==2)
  				arr[i][j] += max(arr[i-1][0],arr[i-1][1]);
  	}
  }
  cout <<  max(arr[n-1][0] , max(arr[n-1][1] , arr[n-1][2])) << endl;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

char c1, c2, c3, c4, c5, c6;

int main() {
	cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6;
	if(c1 == c6 && c2 == c5 && c3 == c4)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ipair pair<int,int>
vector<ipair>adj_list[100005];
vector<int>dist(100005,LLONG_MAX);
vector<int>parent(100005,-1);
void dijikstra(int src)
{
    dist[src]=0;
    priority_queue<ipair,vector<ipair>,greater<ipair>>pq;
    pq.push(make_pair(dist[src],src));
    
    while(!pq.empty())
    {
        int u=pq.top().second;
        pq.pop();
        
        for(auto p:adj_list[u])
        {
            int v=p.first;
            int wt=p.second;
            if(dist[v]>dist[u]+wt)
            {
                parent[v]=u;
                dist[v]=dist[u]+wt;
                pq.push(make_pair(dist[v],v));
            }
        }
    }
}
int32_t main()
{
  int n;int m;cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
      int u;int v;
      cin>>u>>v;
      adj_list[u].push_back(make_pair(v,1));
      adj_list[v].push_back(make_pair(u,1));
  }
  
  dijikstra(1);
  for(int i=2;i<=n;i++)
  {
      if(dist[i]==LLONG_MAX)
      {
      cout<<"No"<<endl;
      return 0;
      }
  }
  cout<<"Yes"<<endl;
  for(int i=2;i<=n;i++)
  cout<<parent[i]<<endl;
  
}
  
  


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

int main(){
  int N;
  cin >> N;
  vector<vector<pair<int64_t,int64_t>>> G(N);
  pair<int64_t,int64_t> P;
  
  for(int i=0; i<N-1; i++){
    int64_t a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    P = make_pair(b,c);
    G.at(a).push_back(P);
    P = make_pair(a,c);
    G.at(b).push_back(P);
  }
  
  int64_t R, K;
  cin >> R >> K;
  vector<vector<int64_t>> ans(R,vector<int64_t>(2));
  for(int i=0; i<R; i++){
    for(int j=0; j<2; j++){
      cin >> ans.at(i).at(j);
    }
  }
  
  queue<int64_t> Q;
  Q.push(K-1);
  vector<int64_t> dist(N,-1);
  dist.at(K-1) = 0;
  while(Q.size()){
    int64_t x = Q.front();
    Q.pop();
    for(int i=0; i<G.at(x).size(); i++){
      P = G.at(x).at(i);
      int64_t a = P.first;
      int64_t b = P.second;
      if(dist.at(a) == -1){
        dist.at(a) = dist.at(x) + b;
        Q.push(a);
      }
    }
  }
  
  for(int i=0; i<R; i++){
    int m = ans.at(i).at(0);
    int n = ans.at(i).at(1);
    cout << dist.at(m-1) + dist.at(n-1) << endl;
  }
  
}

Measured memory_bytes: 15472
#include <iostream>
using namespace std;
typedef long long ll;

ll N,X;

ll gcd(ll n, ll m){
	if(n%m==0) return m;
	else return gcd(m,n%m);
}

int main(){
	cin >> N >> X;
	cout << 3*(N-gcd(N,X)) << endl;
}

Measured memory_bytes: 256
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
 while t[x]>=0:x=t[x]
 return x
def u(x,y):
 x,y=r(x),r(y)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=c=0;b=[]
for v in a:d[r(i)]+=v,;i+=1
k=n+~m
if k<1:exit(print(0))
k*=2
for r,p in d.items():p.sort();c+=p.pop(0);b+=p;k-=1
print(k>len(b)and'Impossible'or c+sum(sorted(b)[:k]))

Measured memory_bytes: 35608
import itertools

n, m, q = list(map(int, input().split()))
nums = []
for i in range(q):
    nums.append(list(map(int, input().split())))
a = list(itertools.combinations_with_replacement(
    [e for e in range(1, m + 1)], n))
for i in range(len(a)):
    a[i] = sorted(a[i])
results = [0]
for j in range(len(a)):
    max_value = 0
    for i in range(q):
        if a[j][nums[i][1] - 1] - a[j][nums[i][0] - 1] == nums[i][2]:
            max_value += nums[i][3]
    else:
        results.append(max_value)

print(max(results))


Measured memory_bytes: 32612
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        if (x <= y) {
            ans = Math.min(ans, Math.abs(x - y));
        }
        if (-1 * x <= y) {
            ans = Math.min(ans, Math.abs(-1 * x - y) + 1);
        }
        if (x <= -y) {
            ans = Math.min(ans, Math.abs(x + y) + 1);
        }
        if (-1 * x <= -1 * y) {
            ans = Math.min(ans, Math.abs(y - x) + 2);
        }
        System.out.println(ans);
        return;
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;


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

const int MOD = 1e9 + 7;

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    vector<P> x(n);
    rep(i,n)cin>>x[i].first>>x[i].second;
    vector<int> a(n),b(n);
    rep(i,n){
        a[i]=x[i].first+x[i].second;
        b[i]=x[i].first-x[i].second;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end()  );
    cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<endl;
}


Measured memory_bytes: 9520
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    int A,B,C;
    
    cin >> A >> B >> C;

    if(A == B){
      cout << C;
    }else if(B == C){
      cout << A;
    }else{
      cout << B;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
import itertools

def spl(s, t):
    lst = list(s)
    for x in reversed(t):
        lst.insert(x, '+')
    return eval(''.join(lst))


def main():
    nums = input()
    length = len(nums)
    total = 0
    for i in range(length):
        for ts in itertools.combinations(range(1, length), i):
            total += spl(nums, ts)
    print(total)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N, K = map(int, input().split())
from itertools import accumulate
As = [0] + list(map(int, input().split()))
As = list(accumulate(As))
L = len(bin(As[-1]))-2
xs = []
for i in range(N+1):
    for j in range(i+1, N+1):
        xs.append(As[j] - As[i])
xs.sort()
ts = set(range(N*(N+1)//2))
for j in range(L-1,-1,-1):
    nts = set()
    for i in ts:
        if (xs[i]>>j)%2:
            nts.add(i)
    if len(nts) >= K:
        ts = nts
c = 0
r = 0
for i in ts:
    c += 1
    if r == 0:
        r = xs[i]
    else:
        r = r&xs[i]
    if c == K:
        break
print(r)


Measured memory_bytes: 91616
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9
#define vint vector<int>

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

//int r[2000];
//int g[2000];
//int b[2000];

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

    ll r_count=0, g_count = 0, b_count = 0;
    REP(i, 0, n){
        if(st[i] == 'R'){r_count++;}
        else if (st[i] == 'G'){g_count++;}
        else{b_count++;}
    }

    ll ans = r_count * g_count *b_count;

    for(int j = 1; j < n; j++){
        for(int k = j + 1; k < n; k++){
            int i = 2*j - k;
            if(i < 0)continue;
            if(st[i] != st[j] and st[j] != st[k] and st[k] != st[i]){
                ans = ans - 1;
            }
        }
    }

    p(ans);
}

Measured memory_bytes: 3628
/* 
    Author : Jeff Ahn
    Sun 21 Jun 2020 04:45:00 PM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

const int mxn = 1e5+1;
int f[mxn];

signed main() {
  fastio;
  int n; cin >> n;
  memset(f, 0, sizeof(f));
  int sum = 0;
  rep(i,n) {
    int ai;
    cin >> ai;
    f[ai]++;
    sum += ai;
  }

  int q;
  cin >> q;
  while(q--) {
    int bi, ci;
    cin >> bi >> ci;
    sum -= (bi * f[bi]);
    f[ci] += f[bi];
    int fb = f[bi];
    f[bi] = 0;
    sum += (ci * fb);
    cout << sum << endl;
  }

}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int c[3][3];
  rep(i, 3) rep(j, 3)
    cin >> c[i][j];
  int a[3] = {}, b[3];
  rep(i, 3)
    b[i] = c[0][i]-a[0];
  rep(i, 3)
    a[i] = c[i][0]-b[0];
  rep(i, 3) rep(j, 3) {
    if (a[i]+b[j] != c[i][j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n;
	cin>>n;
	ll arr[n], first = INT_MIN, second=INT_MIN;
	for(ll i=0;i<n;i++) {
	    cin>>arr[i];
	    if (arr[i] >= first) 
        { 
            second = first; 
            first = arr[i]; 
        }
        else if (arr[i] > second) 
            second = arr[i]; 
	}
	for(ll i=0;i<n;i++) {
	    if(arr[i] != first) cout<<first;
	    else cout<<second;
	    cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long int ll;
#pragma GCC optimize "trapv"
#define fi first
#define sec second
#define pb push_back
//#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}
int main(){
	fio;
	int test;
	//cin>>test;
	test=1;
	while(test--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    bool ans = false;
    rep(i, n - m + 1)rep(j, n - m + 1){
        bool match = true;
        rep(k, m){
            if(b[k] != a[i + k].substr(j, m)) match = false;
        }
        if(match) ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const long double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const long double PI=acos(-1);
 long double a,b,x;
long double check(long double ang){

    if(ang > PI/2.0 -eps){
        return 0.0;
    }
    if(a*tan(ang)<= b){
            return a * a * b - a * a * a * tan(ang) / 2.0;

    }
    else{
        return b * b / tan(ang) * a / 2.0;
    }

}

long double BS(){
    long double l=0.0,r=PI/2.0;
    int T=100;
    long double ans=0.0;
    while(T--){
        long double mid= (l+r)/2.0;
        if(check(mid) < x){
            r=mid;
        }
        else{
            l=mid;
            ans=mid;
        }
    }
   // cout<<ans<<endl;
    ans= (ans*(180.0/PI));
    return ans;
}
int main(){
    GO();

    cin>>a>>b>>x;

    cout<<fixed<<setprecision(7)<<BS()<<endl;
}




Measured memory_bytes: 640
import sys

N, M = list(map(int, input().split()))
if M == 0:
  h = []
else:
  h = sys.stdin.readlines()
  h = set(map(int, list(set(h))))

if N==1:
  print(1)
elif N==2:
  if M==1:
    print(1)
  else:
    print(2)
else:
  DP = []
  DP.append(1)
  if 1 in h:
    DP.append(-1)
  else:
    DP.append(1)
  for i in range(2,N+1):
    if DP[i-2]<0 and DP[i-1]<0:
      print(0)
      exit()
    DP.append(0)
    if i in h:
      DP[i] = -1
    else:
      if DP[i-1]>=0:
        DP[i] += DP[i-1]
      if DP[i-2]>=0:
        DP[i] += DP[i-2]
      DP[i] = DP[i] % 1000000007
  print(int(DP[N]))

Measured memory_bytes: 63572
#include<bits/stdc++.h>
using namespace std;
#define M 200005
#define ll long long
#define mo 1000000007
ll ksm(ll a,int k) {
    ll s=1;
    while(k)
    {
        if(k&1) s=1ll*s*a%mo;
        a=1ll*a*a%mo;
        k>>=1;
    }
    return s;
}
int read() {
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return s*w;
}
struct edge{
    int t,nxt;
}e[M*4];
int head[M*2],tot;
void add(int st,int t) {
    e[++tot].nxt=head[st],e[tot].t=t,head[st]=tot;
}
struct Edge{
    int u,v,w;
    Edge(int r_u=0,int r_v=0,int r_w=0) {u=r_u,v=r_v,w=r_w;}
}E[M];
bool cmp(Edge E1,Edge E2) {
    return E1.w<E2.w;
}
int f[M];
int find(int x) {
    if(x==f[x]) return x;
    return f[x]=find(f[x]);
}
int T,n,m;
ll X,sum,ans;
int nd[M],tot2,val[M*2];
int F[M*2][20],dep[M*2];
void dfs(int x,int fa) {
    F[x][0]=fa,dep[x]=dep[fa]+1;
    for(int i=1;i<20;i++) F[x][i]=F[F[x][i-1]][i-1];
    for(int i=head[x];i;i=e[i].nxt)
    {
        int to=e[i].t;
        if(to==fa) continue ;
        dfs(to,x);
    }
}
int getlca(int p1,int p2) {
    if(dep[p1]<dep[p2]) swap(p1,p2);
    for(int i=19;i>=0;i--) if(F[p1][i]&&dep[F[p1][i]]>=dep[p2]) p1=F[p1][i];
    if(p1==p2) return p1;
    for(int i=19;i>=0;i--) if(F[p1][i]&&F[p2][i]&&F[p1][i]!=F[p2][i]) p1=F[p1][i],p2=F[p2][i];
    return F[p1][0];
}
int c1,c2;
void calc() {
    for(int i=1;i<=m;i++)
    {
        int u=E[i].u,v=E[i].v,lca;
        lca=getlca(u,v);
        if(sum-val[lca]+E[i].w==X) c2++;
        else if(sum-val[lca]+E[i].w<X) c1++;
    }
}
void Kru() {
    sum=0;
    for(int i=1;i<=n;i++) f[i]=i,nd[i]=i;
    sort(E+1,E+m+1,cmp);
    tot2=n;
    for(int i=1;i<=m;i++)
    {
        int u=E[i].u,v=E[i].v;
        if(find(u)==find(v)) continue ;
        ++tot2;
        val[tot2]=E[i].w;
        add(nd[find(u)],tot2),add(tot2,nd[find(u)]);
        add(nd[find(v)],tot2),add(tot2,nd[find(v)]);
        f[find(u)]=find(v);
        nd[find(u)]=tot2;
        sum+=E[i].w;
    }
    dfs(tot2,0);
}
void work() {
    Kru();
    if(sum>X) cout<<0<<'\n';
    else
    {
        c1=0,c2=0;
        calc();
        if(sum==X) ans=(ksm(2,m)-ksm(2,m-c2+1)+mo)%mo;
        else ans=(ksm(2,m-c1+1)-ksm(2,m-c1-c2+1)+mo)%mo;
        cout<<ans<<'\n';
    }
    for(int i=1;i<=tot2;i++) head[i]=0;
    tot=0;
}
int main()
{
    n=read();m=read();cin>>X;
    for(int i=1,x,y,z;i<=m;i++)
    {
		x=read();y=read();z=read();
		E[i]=Edge(x,y,z);
    }
	work();
    return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    string s;
    cin >> s;
    if(s.find("9") != string::npos)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int []t = new int[3];
for(;;){
	String rank ="A";
	for(int i=0; i<3; i++) t[i] =sc.nextInt();
	if(t[0]==-1 && t[1]==-1 && t[2]==-1) break;

	if((t[0]+t[1])>=65 && (t[0]+t[1])<80) rank ="B";
	if((t[0]+t[1])>=50 && (t[0]+t[1])<65) rank ="C";
	if((t[0]+t[1])>=30 && (t[0]+t[1])<50){
		if(t[2]<50) rank ="D";
		if(t[2]>=50)rank ="C";
	}
	if(t[0]== -1 || t[1]== -1 ) rank ="F";
	if(t[0]+t[1]<30) rank ="F";
	System.out.println(rank);
}
}
}

Measured memory_bytes: 19236
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<bool> t(201, false);
    int x, n;
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        t[p] = true;
    }

    int ans = 0;
    int diff = 1e9;
    for (int i = 0; i <= 200; i++) {
        if (!t[i] && abs(x - i) < diff) {
            ans = i;
            diff = abs(x - i);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3652
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var result int
	switch s {
	case "SUN":
		result = 7
	case "MON":
		result = 6
	case "TUE":
		result = 5
	case "WED":
		result = 4
	case "THU":
		result = 3
	case "FRI":
		result = 2
	case "SAT":
		result = 1
	}
	fmt.Println(result)
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int k,ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int z=1;z<=k;z++){
                ans+=__gcd(i,__gcd(j,z));

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

Measured memory_bytes: 3652
import math
while True:
  n=int(input())
  if n==0:
    break
  else:
    S_list=[]
    for i in range(n):
      score=int(input())
      S_list.append(score)
    S_list.remove(max(S_list))
    S_list.remove(min(S_list))
    print(math.floor(sum(S_list)/len(S_list)))


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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 412

int n;
ll vals[MAXN];
ll prefix[MAXN];
int vis[MAXN][MAXN];
ll dp[MAXN][MAXN];

ll sum(int l, int r)
{
    ll res = prefix[r];
    if (l > 0) res -= prefix[l - 1];
    return res;
}

ll solve(int l, int r)
{
    if (l > r)
        return 0;
    if (l == r)
        return 0;

    if (vis[l][r])
        return dp[l][r];
    vis[l][r] = 1;

    ll res = INF;
    for (int i = l; i < r; i++)
    {
        ll rec1 = solve(l, i);
        ll rec2 = solve(i + 1, r);

        res = min(res, rec1 + rec2 + sum(l, r));
    }
    
    return dp[l][r] = res;
}

int main()
{
    scanf("%d", &n);
    ll aux = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &vals[i]);
        aux += vals[i];
        prefix[i] = aux;
    }

    printf("%lld\n", solve(0, n - 1));
    
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int X;
   cin>>X;
   
   int ans;
   int maxAns=1;
   
       for(int i=2;i<32;i++){
           for(int j=2;j<10;j++){
               ans=pow(i,j);
               if(ans>X){
                   break;
               }
               maxAns=max(maxAns,ans);
           }
       }
       cout<<maxAns<<endl;
   
   
   
   
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  long long int x,k,d;
  cin>>x>>k>>d;
  double c=0;
  if(x>=0){
    double n=-1-x;
    c=ceil(abs(n/d));
    long long int l;
    if(c<=k){
     l=k-c;
     x=x-(c*d);
   long long  int r=x+d;
    if(l%2==0)
        cout<<abs(x);
    else
        cout<<abs(r);
  }
  else{
    x=x-(k*d);
    cout<<abs(x);
  }
  }
  else{
     double n=1+x;
    c=ceil(abs(n/d));
    long long int l;
    if(c<=k){
     l=k-c;
     x=x+(c*d);
   long long  int r=x-d;
    if(l%2==0)
        cout<<abs(x);
    else
        cout<<abs(r);}
        else{
           x=x+(k*d);
           cout<<abs(x);
        }
  }
}


Measured memory_bytes: 3760
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

void process(vector<vector<pair<int, int>>> & children, vector<bool> & color, vector<bool> & visited, int i) {
    for (auto const & j: children[i]) {
        if (!visited[j.first]) {
            visited[j.first] = true;
            if (j.second % 2) color[j.first] = !color[i];
            else color[j.first] = color[i];
            process(children, color, visited, j.first);
        }
    }
}

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

    vector<vector<pair<int, int>>> children(N);

    for (int n = 0; n < N - 1; n++) {
        int a, b, c;
        cin >> a >> b >> c;

        children[a - 1].push_back(make_pair(b - 1, c));
        children[b - 1].push_back(make_pair(a - 1, c));
    }

    vector<bool> visited(N);
    for (int n = 0; n < N; n++) visited[n] = false;

    vector<bool> color(N);
    color[0] = true;
    process(children, color, visited, 0);

    for (int n = 0; n < N; n++) {
        if (color[n]) cout << 0 << endl;
        else cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 9472
#include<stdio.h>

int main(void){
  int n,m,i,a,sum;
  sum = 0;
  scanf("%d %d", &n, &m);
  for(i=0;i<m;i++){
    scanf("%d", &a);
    sum += a;
  }
  if(sum > n)
    printf("-1");
  else
    printf("%d", n-sum);
  return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	int mid;
	while( left < right ){
		mid = (left+right)/2;
		if( key == A[mid] )return 1;
		if( key > A[mid] )left = mid + 1;
		else if ( key < A[mid] )right = mid;
	}
	return 0;
}

int main(){
	int i, q, k, 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",&k);
		if( binarySearch(k)) sum++;
	}
	printf("%d\n", sum);
	
	return 0;
}



Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 5000000000000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, maxi, x[55], y[55], ans = INF;
int max, may, mix, miy;
signed main() {
	cin >> n >> maxi;
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	rep(i, n) {
		rep(j, n) {
			if (x[i] <= x[j])continue;
			rep(k, n) {
				rep(l, n) {
					if (y[k] <= y[l])continue;
					int cnt = 0;
					rep(m, n) {
						if (x[m] <= x[i] && x[m] >= x[j] && y[m] <= y[k] && y[m] >= y[l])cnt++;
					}
					if (cnt >= maxi) {
						ans = min(ans, (x[i] - x[j])*(y[k] - y[l]));
					}
				}
			}
		}
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string S; cin>>S; 
  int s0=0,s1=0;
  for(int i=0;i<S.size();i++){
    if((S[i]-'0')!=(i%2?1:0))s0++;
    if((S[i]-'0')!=(i%2?0:1))s1++;
  }

  cout<<min(s0,s1)<<endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s, t; cin >> s >> t;
	int S = s.size(), T = t.size();
	vector<vector<int> > dp(S + 1, vector<int>(T + 1));
	for (int i = 1; i <= S; ++i) {
		for (int j = 1; j <= T; ++j) {
			if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	string ans;
	while (S && T) {
		if (dp[S][T] == dp[S - 1][T]) S--;
		else if (dp[S][T] == dp[S][T - 1]) T--;
		else {
			ans = s[S - 1] + ans;
			S--, T--;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	vector < vector < char >>a(H, vector < char >(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}

	vector < int >whiteColumn(H);
	vector < int >whiteRow(W);

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				whiteColumn[i] = 1;
				whiteRow[j] = 1;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		bool enabledRow = false;
		for (int j = 0; j < W; j++) {
			if (whiteColumn[i] == 1 && whiteRow[j] == 1) {
				cout << a[i][j];
				enabledRow = true;
			}
		}
		if (enabledRow)
			cout << "\n";
	}

	return 0;
}


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

int gcc(int a,int b){
  if(b==0)return a;
  if(a>b){return gcc(b,a%b);
  }else return gcc(a,b%a);
}

int main(){
  double i,N,K,x,y;
  char ss[10000];
  scanf("%lf",&N);
  scanf("%lf",&K);
  scanf("%lf",&x);
  scanf("%lf",&y);
  printf("%lf ",((double)(N*K))/2.0);
  if(x*2==N && y*2==K){
	  printf("1");
  }else{
	  printf("0");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 12
using namespace std;

int main() {
	int A, B, C, ans;
	cin >> A >> B >> C;
	if(C > A + B + 1)
		C = A + B + 1;
	cout << B + C << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    n -= k;
    cout << (k == 1 ? 0 : n) << endl;
}


Measured memory_bytes: 3636
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextInt()
    val s = sc.nextInt()

    var result = 0
    for (x in 0..k) {
        for (y in 0..k) {
            if (x + y > s) break
            if (s - (x + y) <= k) {
                result++
            }
        }
    }

    print(result)
}

Measured memory_bytes: 31392
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,D;
	cin>>N>>D;
	vector<vector<int>>X(20);
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<D;j++)
		{
			int p;
			cin>>p;
			X[i].push_back(p);
		}
	}
	int res=0;
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			int t=0;
			for(int k=0;k<D;k++)
				t+=(int)pow(X[i][k]-X[j][k],2);
			for(int k=0;k<=t;k++)
				if(k*k==t)
				{
					res++;
					break;
				}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,x,y;
    cin>>n>>m>>l>>r;
    x=m/l - (n-1)/l;
    y=m/r -(n-1)/r;
    ll p=(l*r)/__gcd(l,r);
    ll q=m/p - (n-1)/p;
    cout<<((m-n+1)-(x+y-q))<<"\n";
    return 0;
}



Measured memory_bytes: 3604
#!/usr/bin/env python3
from math import pi, atan
a, b, x = map(int, input().split())
y = x / a
if y / b < a / 2:
    d = y / b
    th = pi / 2 - atan(2 * d / b)
else:
    d = y / a
    th = atan(2 * (b - d) / a)
print(th * 180 / pi)


Measured memory_bytes: 2940
H,W=map(int,input().split()[:2])
aHW=[input() for _ in range(H)]
ignoreH=[]
ignoreW=[]

for i in range(H):
	flg=True
	for j in range(W):
		if aHW[i][j]=='#':
			flg=False
			break
	if flg:
		ignoreH.append(i)

for i in range(W):
	flg=True
	for j in range(H):
		if aHW[j][i]=='#':
			flg=False
			break
	if flg:
		ignoreW.append(i)


for i in range(H):
	if i in ignoreH:
		continue
	for j in range(W):
		if j in ignoreW:
			continue
		print(aHW[i][j],end="")
	print()


Measured memory_bytes: 4468
#include<ios>

int main(){
    char cC;
    scanf("%c",&cC);
    if ( cC == 'a' || cC == 'i' || cC == 'u' || cC == 'e' || cC == 'o' ) {
        printf("vowel\n");
    }else{
        printf("consonant\n");
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
f = []
for i in range(n):
	ff = list(map(int, input().split()))
	f.append(ff)
p = []
for i in range(n):
	pp = list(map(int, input().split()))
	p.append(pp)
ans = -10**10
for i in range(1, 2**10):
	tmp = 0
	for j in range(n):
		c = 0
		for k in range(10):
			if (i >> k) & 1 and f[j][k] == 1:
				c += 1
		tmp += p[j][c]
	ans = max(ans, tmp)
print (ans)


Measured memory_bytes: 3064
#include <iostream>

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

using namespace std;

int main(int argc, char const* argv[])
{
    int a, b;
    cin >> a >> b;

    cout << (a + b / 2) << "\n";

    return 0;
}


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 n; cin>>n;
    int ans=MOD;
    for(int i=1; i<n; i++){
        int a=i, b=n-i;
        int suma=0, sumb=0;
        while(a>0){
            suma+=(a%10);
            a/=10;
        }
        while(b>0){
            sumb+=(b%10);
            b/=10;
        }
        ans=min(ans, suma+sumb);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int NR= 2e5 + 5 ;
ifstream in("viitor.in");
ofstream out("viitor.out");

int x[32]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},k;

int main()  {
    cin >> k ;
    cout << x [ k - 1 ] ;
    return 0;
}


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

const int maxN=3010;
const int Mod=1e9+7;

int n,m;
int F[maxN][maxN][2];

void Plus(int &x,int y);
int main(){
    scanf("%d%d",&n,&m);
    F[0][0][1]=1;
    for (int i=1;i<=n;i++) F[0][i][0]=1;
    for (int i=0;i<m;i++) for (int j=0;j<=n;j++) for (int k=0;k<=1;k++){
        if (!F[i][j][k]) continue;
        if (j>=1) Plus(F[i+1][j-1][k|(j==1)],F[i][j][k]),Plus(F[i+1][j][k|(j==1)],F[i][j][k]);
        if (j<n) Plus(F[i+1][j][k],F[i][j][k]),Plus(F[i+1][j+1][k],F[i][j][k]);
    }
    int Ans=0;
    for (int i=0;i<=n;i++) Plus(Ans,F[m][i][1]);
    printf("%d\n",Ans);return 0;
}
void Plus(int &x,int y){
    x+=y;if (x>=Mod) x-=Mod;return;
}

Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main(void){
    int n,a[100],i;
    cin>>n;
    for(i=0;i<n;i++){
    	cin>>a[i];
    }
    for(i=n-1;i>=0;i--){
    	cout<<a[i];
    	if(i>0) cout<<" ";
    }
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long e,f,g ,h;
  e = a*c;
  f = b*d;
  h = max(e,f);
  e = a*d;
  f = b*c;
  g = max(e,f);
  h = max(g,h);
  if((a<=0  && b>=0) || (c<=0 && d>=0))
    h = max(h,(long long)0);
  cout<<h;
return 0;
}

Measured memory_bytes: 3656
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
L = 100
dp = [[-float('inf')]*2 for _ in range(L+1)]
dp[0][0] = 0

for i in range(L):
    Ki = (K>>(L-1-i))&1
    
    for j in range(2):
        for k in range(2 if j else Ki+1):
            add = 0
            
            for Ai in A:
                add += k^((Ai>>(L-1-i))&1)
            
            dp[i+1][j|(k<Ki)] = max(dp[i+1][j|(k<Ki)], dp[i][j]+add*2**(L-1-i))
            
print(max(dp[L]))


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

int main()
{
        double Y;
	double X = 100.0;
	long long n=0;


	scanf("%lf",&Y);
	while(X<Y)
	{
		X=floor(X*1.01);
		n++;
	}
	printf("%lld\n",n);
	return 0;
}


Measured memory_bytes: 1732
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Text;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(Console.ReadLine());
	int[] G() => Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var I = G();
		int A = I[0], B = I[1], N = A + B;
		if (A <= B) Console.WriteLine("Impossible");
		else
		{
			var st = new Stack<int>();
			for (var i = 0; i < A + B; i++)
			{
				if (st.Count == 0 || Ask(st.Peek(), i)) st.Push(i);
				else st.Pop();
			}
			var h = st.Peek();
			var sb = new StringBuilder(N);
			for (var i = 0; i < N; i++) sb.Append(Ask(h, i) ? 1 : 0);
			Console.WriteLine("! " + sb.ToString());
		}
		Console.Out.Flush();
	}
	bool Ask(int a, int b)
	{
		Console.WriteLine("? {0} {1}", a, b);
		Console.Out.Flush();
		return Console.ReadLine() == "Y";
	}
}

Measured memory_bytes: 13856
from collections import defaultdict
from bisect import *

def main():
    idx = defaultdict(list)
    s = input()
    t = input()
    if not set(t) <= set(s):
        print(-1)
        exit()
    for i, c in enumerate(s):
        idx[c] += [i]
    pre = -1
    roop = 0
    for c in t:
        koho = idx[c]
        ki = bisect_left(koho, pre + 1)
        if ki < len(koho):
            pre = koho[ki]
        else:
            pre = koho[0]
            roop += 1
    print(len(s) * roop + pre + 1)

main()


Measured memory_bytes: 9844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> p(m);
  vector<int> y(m);
  vector<int> py[100001];
  for(int i=0;i<m;i++){
    cin>>p[i]>>y[i];
    py[p[i]].push_back(y[i]);
  }
  for(int i=0;i<n;i++){
    sort(py[i+1].begin(),py[i+1].end());
  }
  for(int i=0;i<m;i++){
    printf("%06d%06d\n",p[i],(lower_bound(py[p[i]].begin(),py[p[i]].end(),y[i]))-py[p[i]].begin()+1);
  }
  return 0;
}


Measured memory_bytes: 7808
h, w = map(int, input().split())
alp = [0] * 26
for i in range(h):
        for c in input(): alp[ord(c)-ord('a')] += 1

m2 = (h * (w%2) + w * (h%2)) // 2
one = h%2 and w%2
cant = False
for i in alp:
        if i%4!=0:
                if i%4==3:
                        if m2: m2 -= 1
                        else: cant = True
                        if one: one = False
                        else: cant = True
                if i%4==2:
                        if m2: m2 -= 1
                        else: cant = True
                if i%4==1:
                        if one: one = False
                        else: cant = True
print("YNeos"[cant::2])

Measured memory_bytes: 3064
#include <stdio.h>

void PrinFrame(int Height, int Width)
{
    for(int i = 0; i < Width; ++i){
        printf("#");
    }
    printf("\n");
    if(Height < 2) return;
    for(int i = 0; i < Height - 2; ++i){
        printf("#");
        if(Width < 2) break;
        for(int j = 0; j < Width - 2; ++j){
            printf(".");
        }
        printf("#\n");
    }
    for(int i = 0; i < Width; ++i){
        printf("#");
    }
    printf("\n");
}

void PrintFrames()
{
    while(true){
        int Height = 0;
        int Width = 0;
        scanf("%d %d", &Height, &Width);
        if(Height == 0 && Width == 0) return;
        PrinFrame(Height, Width);
        printf("\n");
    }
}

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


Measured memory_bytes: 2532
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
// 35419                                                                                                 
ll gcd(ll m, ll n) {
  while(n != 0LL) {
    ll r = m % n;
    m = n; n = r;
  }
  return m;
}
ll lcm(ll m, ll n) {
  return m / gcd(m,n) * n;
}
int main() {
  int N; cin>>N;
  vector<ll> a(N);
  REP(i,N) cin>>a[i];
  ll ans = 0;
  REP(i,N) {
    ans += a[i];
  }
  ans -= N;
  cout << ans << endl;

  return 0;
}



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


int main() {
    
    long long  K,N;
    vector<long long>A(N);
    cin >> K >> N ;

    for (int i =0;i<N;i++)cin >> A[i];

    int ans = A[N-1]-A[0];

    for(int i=0;i<N-1;i++){
        if(K-(A[i+1]-A[i])<ans)ans = K-(A[i+1]-A[i]);
    }

    cout << ans << endl;

}   




Measured memory_bytes: 33024
int_n = int(input())
ar_int = list()
for i in range(int_n):
    ar_int.append(int(input()))

target = 1
counter = 0

while counter < int_n:
    target = ar_int[target - 1]
    counter += 1
    if target == 2: # button 2
        print(counter)
        exit(0)
print(-1)

Measured memory_bytes: 7084
# https://atcoder.jp/contests/abc149/tasks/abc149_b
a, b, k = map(int, input().split())

if a - k >= 0:
    print(a - k, b)
else:
    if a + b - k >= 0:
        print(0, a + b - k)
    else:
        print(0, 0)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10){
        cout<<a*b<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    
   return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.List (transpose, partition)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve <$> replicateM n (map read <$> words <$> getLine) >>= print
    main

solve :: [[Int]] -> Int
solve = f 0
  where f pt xss | cpt == 0 = pt
                 | otherwise = f (pt + cpt) zss
          where (cpt, yss) = foldr g (0, []) xss
                g [a, b, c, d, e] (ct, as) | all (==a) [b, c, d, e] = (ct + 5 * a, [0,0,0,0,0]:as)
                                           | all (==a) [b, c, d] = (ct + 4 * a, [0,0,0,0,e]:as)
                                           | all (==b) [c, d, e] = (ct + 4 * b, [a,0,0,0,0]:as)
                                           | all (==a) [b, c] = (ct + 3 * a, [0,0,0,d,e]:as)
                                           | all (==b) [c, d] = (ct + 3 * b, [a,0,0,0,e]:as)
                                           | all (==c) [d, e] = (ct + 3 * c, [a,b,0,0,0]:as)
                                           | otherwise = (ct, [a,b,c,d,e]:as)
                zss = transpose . map h . transpose $ yss
                h xs = let (ys, zs) = partition (==0) xs in ys ++ zs



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

int main() {
    long power = 1;
    int N;
    cin >> N;
    long c = 1000000007;
    for (int i=1; i<=N; i++){
        power *= i;
        power = power % c;
    }
    cout << power << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX (128)
char s[MX];
int L,X=INF;
int go(char c){
    int S=0,X=0,f=0;
    F(L)if(s[i]==c&&!f)X=max(X,S),S=0;
        else ++S;
    return max(X,S);
}
int main(void){
    scanf("%s",s),L=strlen(s);
    F(26)X=min(X,go(i+97));
    printf("%d\n",X);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int m, n;
  while (scanf("%d %d", &m, &n) != EOF)
  {
    int a[n], s = 0;
    for (int i = 0; i < n; i++)
    {
      scanf("%d", &a[i]);
      s += a[i];
    }
    printf("%d\n", s <= m ? m - s : -1);
  }
  return 0;
}

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

int main(int argc, char const *argv[]) {
  int n, sum=0;
  int a[25],b[25],c[25];
  cin>>n;
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<n; i++) cin>>b[i];
  for(int i=0; i<n-1; i++) cin>>c[i];

  for(int i=0; i<n; i++) sum+=b[i];
  for(int i=1; i<n; i++)
    if(a[i]==a[i-1]+1) sum+=c[a[i]-2];

  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
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 boolean visited[][];
    static int[][] s;
    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int H = scan.nextInt();
        int W = scan.nextInt();
        s = new int[H][W];
        for(int i = 0; i < H; i++) {
            String tmp = scan.next();
            for(int j = 0; j < W; j++){
                if(tmp.charAt(j) == '.')
                    s[i][j] = 0;
                else
                    s[i][j] = 1;
            }
        }

        int ans = 0;
        for(int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                for(int k = i; k < H; k++) {
                    int l;
                    if(k == i)
                        l = j+1;
                    else
                        l = 0;
                    for (; l < W; l++) {
                        if(s[i][j] != 0 || s[k][l] != 0) continue;
                        visited = new boolean[H][W];
//                        System.out.println("start " + i + " " + j + " end " + k + " " + l);
                        int level = bfs(new int[]{i,j}, new int[]{k,l});
//                        System.out.println("level " + level);
                        ans = Math.max(ans, level);
                    }
                }
            }
        }

        os.println(ans);
    }

    static int[][] dirs={{0, 1}, {0, -1}, {-1, 0}, {1, 0}};

    public static int bfs(int[] start, int[] end){
        visited[start[0]][start[1]] = true;
        int level = 0;
        Queue<int[]> queue = new LinkedList<>();
        queue.add(start);
        while (!queue.isEmpty()) {
            Queue<int[]> queue2 = new LinkedList<>();
            while (!queue.isEmpty()) {
                int[] p = queue.remove();
                if (p[0] == end[0] && p[1] == end[1])
                    return level;
                for (int[] dir : dirs) {
                    int x = p[0] + dir[0];
                    int y = p[1] + dir[1];
                    if (x >= 0 && y >= 0 && x < s.length && y < s[0].length && s[x][y] == 0) {
                        if (!visited[x][y]) {

                            queue2.add(new int[]{x, y});
                            visited[x][y] = true;
                        }
                    }
                }
            }
            queue = queue2;
            level++;
        }

        return level;
    }
}

Measured memory_bytes: 220368