akhauriyash/Code-Regression huggingface dataset:
n = int(input())
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["#" for x in range(20)]))


Measured memory_bytes: 5608
using System;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int amx = a.Max();
    int[] table = new int[amx+1];
    for(int i = 0;i < n;i++){
      for(int j = a[i];j <= amx; j += a[i]) table[j]++;
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
      if(table[a[i]] == 1) ans++;
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 46928
import math
k = int(input())
ansA, ansB, ansC = 0, 0, 0
for a in range(k):
    ansC += a+1
    for b in range(k-a-1):
        GCDab = math.gcd(a+1, a+b+2)
        ansB += GCDab
        for c in range(k-a-b-2):
            GCDabc = math.gcd(GCDab, a+b+c+3)
            ansA += GCDabc
ans = ansA * 6 + ansB * 6 + ansC
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define cout(a) cout << a << endl
int main(){
  string s,t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s < t) cout("Yes");
  else cout("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long
#define db double

using namespace std;
const int N=1e7+10,M=200+10,inf=1<<30;
int rd()
{
	int x=0,w=1;char ch=0;
	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*w;
}
int to[M*M],nt[M*M],c[M*M],hd[M],tot=1;
void add(int x,int y,int z)
{
	++tot,to[tot]=y,nt[tot]=hd[x],c[tot]=z,hd[x]=tot;
	++tot,to[tot]=x,nt[tot]=hd[y],c[tot]=0,hd[y]=tot;
}
int ps,pt,nhd[M],lv[M];
bool bfs()
{
	queue<int> q; 
	for(int i=1;i<=pt;++i) lv[i]=0;
	lv[ps]=1,q.push(ps);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=hd[x];i;i=nt[i])
		{
			int y=to[i];
			if(c[i]>0&&!lv[y])
				lv[y]=lv[x]+1,q.push(y);
		}
	}
	return lv[pt];
}
int dfs(int x,int fw)
{
	if(x==pt) return fw;
	int an=0;
	for(int &i=nhd[x];i;i=nt[i])
	{
		int y=to[i];
		if(c[i]>0&&lv[y]==lv[x]+1)
		{
			int dt=dfs(y,min(fw,c[i]));
			c[i]-=dt,c[i^1]+=dt;
			fw-=dt,an+=dt;
			if(!fw) break;
		}
	}
	return an;
}
int dinic()
{
	int an=0,dt;
	while(bfs())
	{
		memcpy(nhd,hd,sizeof(int)*(pt+1));
		while((dt=dfs(ps,inf))) an+=dt;
	}
	return an;
}
int prm[N],tt;
bool v[N];
int n,a[M],id[M],b[N],ans;

int main()
{
	v[1]=1;
	for(int i=2;i<=10000001;++i)
	{
		if(!v[i]) prm[++tt]=i;
		for(int j=1;i*prm[j]<=10000001;++j)
		{
			v[i*prm[j]]=1;
		    if(i%prm[j]==0) break;
		}
	}
	v[0]=v[2]=1;
	n=rd();
	for(int i=1;i<=n;++i)
	{
		int x=rd();
		b[x]^=1,b[x+1]^=1;
	}
	n=0;
	for(int i=1;i<=N-5;++i)
		if(b[i]) a[++n]=i;
	ps=0,pt=n+1;
	for(int i=1;i<=n;++i)
	{
		if(a[i]&1)
		{
			add(ps,i,1),id[i]=tot;
			for(int j=1;j<=n;++j)
				if(!v[abs(a[i]-a[j])])
					add(i,j,1);
		}
		else add(i,pt,1),id[i]=tot;
	}
	ans=dinic();
	for(int i=1;i<=n;++i)
		if(c[id[i]]) a[i]=N+1;
	sort(a+1,a+n+1);
	while(a[n]>N) --n;
	for(int i=1;i<=n;++i)
	{
		if(a[i]>N) continue;
		for(int j=1;j<=n;++j)
			if(i!=j&&a[j]<N&&!((a[i]-a[j])&1))
			{++ans,++ans,a[i]=a[j]=N+1;break;}
	}
	sort(a+1,a+n+1);
	while(a[n]>N) --n;
	ans+=n/2*3;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 53632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n,k;cin >> n >> k;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll sum=0;
    rep(i,k+1){
        if(i<=n){
            //cout << "i=" << i << endl;
            rep(j,i+1){
                vector<ll> vv;
                ll tmp=0;
                //cout << "i,j" << i << "," << j << endl;
                rep(h,j){
                    vv.push_back(v[h]);
                    tmp+=v[h];
                }
                rep(h,i-j){
                    vv.push_back(v[n-h-1]);
                    tmp+=v[n-h-1];
                }
                sort(vv.begin(),vv.end());
                //cout << "vv" << vv << endl;
                ll vvsize = vv.size();
                ll mn=min(k-i,vvsize);
                rep(g,mn){
                    if(vv[g]<0) tmp-=vv[g];
                }
                //cout << "tmp" << tmp << endl;
                sum=max(sum,tmp);
            }
        }else{
            break;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
 
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;
 

void solv1e(){
    string s;
    cin >> s;
    int cpd = 0;
    
    string ans = "";
    rep(i,s.size()){
        
        if (s[i] == '?'){
            ans += 'D';
        }   
        else ans += s[i];
    }
    
    cout << ans;
    
}
void solve(){
    string s;
    int h1,m1,h2,m2;
    int k;
    cin >> h1 >> m1 >> h2 >> m2;
    cin >> k;
    int start = h1*60+m1;
    int end = h2*60+m2;
    
    //vector<int> a();
    
    cout << max(0,end-start-k);
    
    
}
 
int main(){
    int T;
    T = 1;
    while(T--){
        solve(); 
    }
}
 

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

int main(){
  int A, B, N;
  cin >> N;
  int ans = 10000;
  for(int i=1; i<=N/2; i++){
    int a=i, b=N-i;
    int tmp =0;
    while(a!=0){
      tmp += a%10;
      a/=10;
    }
    while(b!=0){
      tmp += b%10;
      b/=10;
    }
    if(tmp<ans) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
int d[11][11];
int c[101][101];

int main()
{
	//freopen("1.in","r",stdin);
	int a,b;
	cin>>a>>b;
	rep(i,1,a)
	rep(j,1,b)cin>>d[i][j];
	int n=101+101;
	rep(x,0,100)
	rep(y,0,100)
	{
		rep(i,1,a)
		rep(j,1,b)chmax(c[x][y],d[i][j]-(i*x+j*y));
	}
	rep(i,1,a)
	rep(j,1,b)
	{
		rep(x,0,100)
		rep(y,0,100)
		if(i*x+j*y+c[x][y]==d[i][j])goto have;
		puts("Impossible");
		return 0;
		have : ;
	}
	puts("Possible");
	printf("%d %d\n",n,101*101+100*2);
	rep(x,1,100)printf("%d %d X\n",x,x+1);
	rep(y,1,100)printf("%d %d Y\n",n-y,n-y+1);
	rep(x,0,100)
	rep(y,0,100)printf("%d %d %d\n",1+x,n-y,c[x][y]);
	printf("%d %d\n",1,n);
}

Measured memory_bytes: 384
from fractions import gcd
from functools import reduce


def lcm_base(x,y):
    return (x*y)//gcd(x,y)


def lcm(A):
    return reduce(lcm_base,A,1)


n,m=map(int,input().split())
A=list(map(int,input().split()))
num=lcm(A)
semi=num//2

ans=0
if any([True for i in range(n) if semi%A[i]==0]):print(0)
elif semi<=m:
    ans +=1
    m -=semi
    ans +=m//num
    print(ans)
else:print(0)

Measured memory_bytes: 89580
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=310;
int mod;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,m,C[N][N],f[N][N],s[N][N];
int main() {
    n=gi(),m=gi(),mod=gi();
    for(int i=0;i<=n;i++) {
        C[i][0]=1;
        for(int j=1;j<=i;j++) C[i][j]=add(C[i-1][j],C[i-1][j-1]);
    }
    for(int i=m;~i;i--) f[1][i]=1,s[1][i]=add(s[1][i+1],1);
    for(int i=2;i<=n+1;i++) {
        for(int j=0;j<=m;j++)
            for(int k=1;k<i;k++) inc(f[i][j],1ll*C[i-2][k-1]*s[k][j+1]%mod*f[i-k][j]%mod);
        for(int j=m;~j;j--) s[i][j]=add(s[i][j+1],f[i][j]);
    }
    printf("%d\n",f[n+1][0]);
    return 0;
}


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

using namespace std;

int main() {
  int num;
  cin >> num;
  vector<int> fis(num);
  for(int i=0;i < num; i++){
    cin >> fis[i];
  }
  for(int i=num-1;i >= 0; i--){
    if(i==num-1)cout << fis[i];
    else{
      cout <<" "<< fis[i];
    }
  }
  cout << endl;
}


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

int main() {
	int a, b;
	vector<pair<int, int> > v;
	cin >> a >> b;
	int c, d;
	while(cin >> c >> d) {
		if (d <= b) {
			v.push_back(make_pair(c, d));
		}
	}

	sort(v.begin(), v.end());
	if (v.size() == 0) {
		cout << "TLE" << endl;
		return 0;
	}

	cout << v[0].first << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        double tmp = 0;
        double road = 0;
      
        for(int i = 0; i < N ; i++){
          x[i] = sc.nextInt();
          y[i] = sc.nextInt();
        }
      
        for(int i = 0; i < N; i++){
          for(int j = i + 1; j < N; j++){
            tmp = Math.pow(x[i]-x[j],2) + Math.pow(y[i]-y[j],2);
            road += Math.sqrt(tmp);
          }
        }
      
        if(N == 2){
          System.out.println(road*2/2);
        }else if(N == 3){
          System.out.println(road*4/6);
        }else if(N == 4){
          System.out.println(road*12/24);
        }else if(N == 5){
          System.out.println(road*48/120);
        }else if(N == 6){
          System.out.println(road*240/720);
        }else if(N == 7){
          System.out.println(road*1440/5040);
        }else if(N == 8){
          System.out.println(road*10080/40320);
        }
        
	}
}

Measured memory_bytes: 35756
#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector <int> rep[1001];
string str[1001];
int n;
void saiki(string ten, int ima) {
  for(int i=0;i<rep[ima].size();i++) {
    cout << ten << str[rep[ima][i]] << endl;
    saiki(ten+'.',rep[ima][i]);
  }
}
int main() {
  cin >> n;
  for(int i=1;i<=n;i++) {
    int a;
    cin >>a >> str[i];
    rep[a].push_back(i);
  }
  saiki("",0);
  return 0;
}

Measured memory_bytes: 2244
#include <bits/stdc++.h>
using namespace std;
int ret(int n){
    int i = sqrt(n);
    while(i * (i + 1) <= 2 * n)i++;
    if(i * (i + 1) > 2 * n)i--;
    return i;
}
int main() {
    long long n; cin>>n;
    int ans = 0;
    for(long long i = 2; i * i  <= n; ++i){
        if(n % i == 0){
            int cnt = 0;
            while(n % i == 0){
                cnt++;
                n /= i;
            }
            ans += ret(cnt);
        }
    }
    if(n > 1)ans += 1;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
int a, b, ch=0, A, B=0;
scanf("%d%d", &a , &b);
A=a;
B=b;
for(int i=1;ch<A;i*=10){
    a+=i*B;
    ch++;
}
ch=0;
for(int i=1;ch<b;i*=10){
    B+=i*A;
    ch++;
}
if(A>b){
    printf("%d",a-A);
}else{
    printf("%d", B-b);
}
return 0;
}

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

int main() 
{
	map<int, int>s;
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d;
		cin >> c >> d;
		if (s[d] > c||s[d]==0)s[d] = c;
	}
	auto e = s.end();
	e--;
	cout << e->second << " " << e->first << endl;
}

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

int n;

string i_to_s(int a) {
  if (a == 0) {
    return "0";
  } else {
    return "1";
  }
}

void solve() {
  int s;
  string ans;

  while (n != 0) {
    s = abs(n % 2);
    n -= s;
    n /= (-2);
    ans.insert(0, i_to_s(s));
  }

  if (ans.size() == 0) {
    ans = "0";
  }

  cout << ans << "\n";
  return;
}

int main() {
  cin >> n;

  solve();
  return 0;
}

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

int main() {
	
	int i, N, index=0;
	scanf("%d", &N);
	int A[101];

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

	for (i = 0; i < N; i++) {
		index += 1;
		if (A[i] % 2 == 0) {
			if ((A[i] % 3 != 0 && A[i] % 5 != 0)) {
				printf("DENIED");
				return 0;
			}
		}
	}
	if (index == N) {
		printf("APPROVED");
	}
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n, z, w;
    cin >> n >> z >> w;

    vector<int> card(n);

    rep(i, n){
        cin >> card[i];
    }

    vector<vector<int>> dp(n + 1, vector<int>(n + 1));

    for(int j = n - 1; j >= 1; j--){
        dp[n][j] = abs(card[n - 1] - card[j - 1]);
    }

    dp[n][0] = abs(card[n - 1] - z);

    for(int i = n - 1; i >= 1; i--){
        dp[i][n] = abs(card[n - 1] - card[i - 1]);
    }

    dp[0][n] = abs(card[n - 1] - w);

    for(int k = n - 1; k >= 1; k--){

        int tmpmax = 0;

        for(int j = n; j > k; j--){
            tmpmax = max(tmpmax, dp[k][j]);
        }

        for(int j = k - 1; j >= 0; j--){
            dp[k][j] = tmpmax;
        }

        int tmpmin = INT_MAX;

        for(int i = n; i > k; i--){
            tmpmin = min(tmpmin, dp[i][k]);
        }

        for(int i = k - 1; i >= 0; i--){
            dp[i][k] = tmpmin;
        }
    }

    int ans = 0;

    for(int j = 1; j <= n; j++){
        ans = max(ans, dp[0][j]);
    }

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


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, i, j, k, ans = 0;
    cin >> n;
    ll a[n + 5];
    for (i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (i = 0; i < n; ++i) {
        for (j = i + 1; j < n; ++j) {
            for (k = j + 1; k < n; ++k) {
                if (a[i] != a[j] and a[j] != a[k]) {
                    ans += a[i] + a[j] > a[k];
                }
            }
        }
    }
    cout << ans;

    return 0;
}


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


int X[ 100010 ];
int Y[ 100010 ];
char S[ 100010 ];

int main()
{
int i;
int N;
int K;
int iArr;
int iChk;
int iMax;
int iHS;
bool b;
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;
	cin >> S;

	i = 0;
	iArr = 0;
	b = true;
	while( C = S[ i ] )
	{
		if( b )
		{
			if( C == '0' )
			{
				b = false;
				Y[ iArr ]++;
			}
			else
				X[ iArr ]++;
		}
		else
		{
			if( C == '0' )
				Y[ iArr ]++;
			else
			{
				b = true;
				iArr++;
				X[ iArr ]++;
			}
		}

		i++;
	}

	iChk = iArr;
	iHS = X[ 0 ];
	for( i = 0; i <= iChk && i < K; i++ )
	{
		iHS += Y[ i ];
		iHS += X[ i + 1 ];
	}

	iMax = iHS;
	for( ; i <= iChk; i++ )
	{
		iHS -= X[ i - K ];
		iHS -= Y[ i - K ];
		iHS += Y[ i ];
		iHS += X[ i + 1 ];

		if( iMax < iHS ) iMax = iHS;
	}

	cout << iMax << endl;

	return 0;
}


Measured memory_bytes: 768
//ABC 077
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

int n;
vector<ll> a,b,c;
//bの上にのる数、cの上に載る数を格納
ll bup[100010] = {}, cup[100010] = {};


signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> n;
	ll kari;
	REP(i, n) {
		cin >> kari;
		a.push_back(kari);
	}
	REP(i, n) {
		cin >> kari;
		b.push_back(kari);
	}
	REP(i, n) {
		cin >> kari;
		c.push_back(kari);
	}

	VSORT(a);
	VSORT(b);
	VSORT(c);

	int j = 0;
	REP(i, n) {
		hutatabi:
			if (b[j] > a[i]) {
				//上に乗せられる。
				bup[j]++;
			}
			else {
				//乗せられなければ次にいく
				j++;
				if (j == n) {
					//もしbがなくなってしまえば、ループを抜ける。
					break;
				}
				else {
					goto hutatabi;
				}
			}
	}

	//bupを加算し正しくする。
	FOR(i,1, n) {
		bup[i] += bup[i - 1];
	}

	int k = 0;
	REP(i, n) {
		hutatabi2:
		if (c[k] > b[i]) {
			//上に乗せられる。
			cup[k] += bup[i];
		}
		else {
			//乗せられなければ次にいく
			k++;
			if (k == n) {
				//もしcがなくなってしまえば、ループを抜ける。
				break;
			}else {
				goto hutatabi2;
			}
		}
	}

	//cupを加算し正しくする
	FOR(i, 1, n) {
		cup[i] += cup[i - 1];
	}

	//これらの総和が全通り
	ll total = 0;
	REP(i, n) {
		total += cup[i];
	}

	cout << total << endl;
	



	return 0;

}

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

C2 = [0] * N
C5 = [0] * N

for i in range(N):
    a = str(input())
    dot_idx = -1
    for j in range(len(a)):
        if a[j] == '.':
            dot_idx = j
            break
    # .がないので末尾につける
    if dot_idx == -1:
        a += ".000000000"
    # .の場所に応じて後ろにつける
    else:
        while len(a) < 10+dot_idx:
            a += "0"
    tmps = ""
    for j in range(len(a)):
        if a[j] == '.':continue
        tmps += a[j]
    
    b = int(tmps)

    # 素因数2の個数
    tmp = b
    while tmp > 0 and tmp % 2 == 0:
        tmp //= 2
        C2[i] += 1
    while tmp > 0 and tmp % 5 == 0:
        tmp //= 5
        C5[i] += 1
    C2[i] = min(C2[i], 18)
    C5[i] = min(C5[i], 18)

Cc = [[0] * 19 for _ in range(19)]

for i in range(N):
    Cc[C2[i]][C5[i]] += 1

ans = 0
for i in range(N):
    Cc[C2[i]][C5[i]] -= 1
    l2 = max(0, 18 - C2[i])
    l5 = max(0, 18 - C5[i])
    for j in range(l2, 19):
        for k in range(l5, 19):
            ans += Cc[j][k]
    Cc[C2[i]][C5[i]] += 1

print(ans//2)

Measured memory_bytes: 79576
#include<iostream>
using namespace std;
int A[100];
int N;
void bubbleSort(int A[], int N);
int times=0;
int temp;
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	
	bubbleSort(A, N);
	for (int i = 0; i < N; i++)
	{
		cout<<A[i];
		if (i != N - 1)
			cout << " ";
	}
	cout << endl;
	cout << times<<endl;
}
void bubbleSort(int A[], int N)
{
	int flag = 1;//?????¨?????????????????????????´?
	int i = 0;//???????????¨??????????§???????
	while (flag)
	{
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--)
		{
			if (A[j] < A[j - 1])
			{
				temp=A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				times++;
			}
			flag = 1;//????¬??????¢????????????????????°?°±?°?????????????1?????¶?????§???????????????
		}
		i++;
	}
}

Measured memory_bytes: 3088
c = []
for _ in range(3) :
    c += [list(map(int, input().split()))]
a1 = c[1][0]-c[0][0]
a2 = c[2][0]-c[0][0]
c1 = [c[0][i] + a1 for i in range(3)]
c2 = [c[0][i] + a2 for i in range(3)]
if c[1] == c1 and c[2] == c2 :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int N, Q;
	scanf("%d", &N);
	int A[100001] = {0};
	long long sum = 0;
	while (N--)
	{
		int a;
		scanf("%d", &a);
		A[a]++;
		sum += a;
	}
	scanf("%d", &Q);
	while (Q--)
	{
		int b, c;
		scanf("%d%d", &b, &c);
		sum += A[b] * (c - b);
		A[c] += A[b];
		A[b] = 0;
		printf("%lld\n", sum);
	}
}

Measured memory_bytes: 2120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define int long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int mod = 1e9+7;

int32_t main(){

    int ans = 1;
    for(int i = 1; i <= 5; i++){
        int num;
        cin>>num;

        if(num == 0){
            ans = i;
        }
    }

    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll A[N]; bool op[N-1];
  rep(i,N) {
    cin >> A[i];
    if (i!=N-1) { char top; cin >> top; op[i] = top=='+'; }
  }

  ll dp[N][3] = {}; rep(i,N) fill_n(dp[i],3,-1*LLINF); dp[0][0] = A[0];
  rep(i,N-1) {
    if (op[i]) {
      dp[i+1][0] = max(max(dp[i][0]+A[i+1], dp[i][1]-A[i+1]), dp[i][2]+A[i+1]);
      dp[i+1][1] = max(dp[i][1]-A[i+1], dp[i][2]+A[i+1]);
      dp[i+1][2] = dp[i][2]+A[i+1];
    }
    else {
      dp[i+1][0] = max(max(dp[i][0]-A[i+1], dp[i][1]+A[i+1]), dp[i][2]-A[i+1]);
      dp[i+1][1] = max(max(dp[i][0]-A[i+1], dp[i][1]+A[i+1]), dp[i][2]-A[i+1]);
      dp[i+1][2] = max(dp[i][1]+A[i+1], dp[i][2]-A[i+1]);
    }
  }
  // rep(i,N) debug(dp[i],dp[i]+3);

  ll result = *max_element(dp[N-1],dp[N-1]+3);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6788
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N,M;cin>>N>>M;
    vector<int> F(N,1);
    vector<int> H;
    for(int i=0;i<N;i++){
        int h;cin>>h;
        H.push_back(h);
    }

    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        if(H[a-1]==H[b-1]){
            F[a-1]=0;
            F[b-1]=0;
        }else if(H[a-1]<H[b-1]){
            F[a-1]=0;
        }else{
            F[b-1]=0;
        }
    }

    int ans=0;
    for(auto f : F){
        ans+=f;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4312
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n,k;

 	scanf("%d %d",&n,&k);

 	std::vector<int> a(n);

 	for(auto &x:a)scanf("%d",&x);

 	sort(all(a));
 	ll ans = 0;
 	for(int i=0;i<n-k;i++)ans+=a[i];

 	printf("%lld\n",ans );

}		


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var dict = new Dictionary<long, long>();

            for(int i = 0; i < n; i++) {
                if(dict.ContainsKey(a[i]) == false) {
                    dict.Add(a[i], 0);
                }

                dict[a[i]]++;
            }

            var dict2 = dict.Where(x => x.Value >= 2).ToDictionary(x => x.Key, y => y.Value);

            if(dict2.Count < 2) {
                Console.WriteLine(0);

                Console.Out.Flush();
                return;
            }

            var fmax = dict2.Keys.Max();

            if(dict[fmax] < 4) {
                dict2.Remove(fmax);
            }

            var smax = dict2.Keys.Max();

            Console.WriteLine(fmax * smax);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 29536
S = str(input())

S1 = list(S)

LEN = len(S1)


start0_CONT=0
for i in range(0,LEN):
    if int(i) % 2 == 0:
        if int(S1[i]) == 1:
            start0_CONT=start0_CONT+1
    elif int(i) % 2 == 1:
        if int(S1[i]) == 0:
            start0_CONT=start0_CONT+1
      

start1_CONT=0
for i in range(0,LEN):
    if int(i) % 2 == 0:
        if int(S1[i]) == 0:
            start1_CONT=start1_CONT+1
    elif int(i) % 2 == 1:
        if int(S1[i]) == 1:
            start1_CONT=start1_CONT+1


if start0_CONT > start1_CONT:
    print(start1_CONT)
else:
    print(start0_CONT)

Measured memory_bytes: 3956
r,c=(int(x) for x in input().split())

a=[[0 for i in range(c)] for j in range(r)]
newa=[[0 for i in range(c+1)] for j in range(r+1)]

for i in range(r):
  a[i][:]=(int(x) for x in input().split())


for i in range(r):
  for j in range(c):
    newa[i][c]+=a[i][j]
    newa[r][j]+=a[i][j]
    newa[r][c]+=a[i][j]
    newa[i][j]=a[i][j]

for i in range(r+1):
  for j in range(c+1):
    print(newa[i][j],end='')
    if j<c:
      print(" ",end='')

  print("")


Measured memory_bytes: 6876
import numpy as p
n,M=map(int,input().split())
l=n*3+1
d=p.zeros((l,n*5),p.int64)
d[0][0]=d[1][1]=d[2][2]=d[2][-1]=1
for i in range(3,l):
  d[i]=(d[i-3]*(i-2)*(i-1)+p.roll(d[i-2],-1)*(i-1)+p.roll(d[i-1],1))%M
print(d[-1][:l].sum()%M)

Measured memory_bytes: 481156
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,i = 1,roop = 0,current,a = 0; //N:町の数 K:テレポートする回数 roop:ループしているグラフの要素数
  long long K;
  cin >> N >> K;
  N++;
	vector<int> tel(N); //町関係を保存する
  vector<int> check(N,0);
  for(int i = 1;i < N;i++){
    cin >> tel.at(i);
  }
  current = 1;
  while(1){
    if(check.at(current) != 0){
      roop = i  - check.at(current);
      break;
    }else if(check.at(current) == 0){
      a++;
      check.at(current) = i;
    }
    current = tel.at(current);
  i++;
  }
  if(K > a){
  K = (K - a) % roop;
  for(int i = 0;i < K;i++){
    current = tel.at(current);
  }
  }else{
    current = 1;
    for(i = 0;i < K;i++){
      current = tel.at(current);
    }
  }
  cout << current << endl;
}

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

int main(){
    int S;
    int h,m,s;
    cin >> S;
    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = (S - h * 3600 - m * 60);
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    string s;cin>>s;
    ll n= s.size();
    vector<vector<ll>> a(26,vector<ll>(n+1));
    vector<vector<ll>> res(26,vector<ll>(n+1));
    rep(i,26){
        rep(j,n){
            a[i][j+1]=a[i][j];
            if(s[j]-'a'==i){
                a[i][j+1]+=1;
            }
            res[i][j+1]=a[i][j+1]*2-(j+1);
        }
    }
    //rep(i,n+1)cout<<res[4][i];
    ll index = 0;
    ll indexma = 0;
    ll mi =0;
    bool flag =false;
    rep(i,26){
        if(flag){
            break;
        }
        mi = res[i][0];
        index=0;
        rep(j,n+1){
            if(mi<res[i][j]&&index+1<j){
                flag = true;
                indexma=j;
                //cout<<i<<" "<<j<<endl;
                break;
            }
            else if(res[i][j]<mi&&res[i][j+1]<=mi){
                mi=res[i][j];
                index = j;
            }
        }
    }
    if(flag){
        cout<<index+1<<" "<<indexma<<endl;
    }
    else{
        cout<<-1<<" "<<-1<<endl;
    }
}

Measured memory_bytes: 41968
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayDeque;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            ArrayDeque<Integer> deq = new ArrayDeque<>();
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    deq.offerLast(a[i]);
                } else {
                    deq.offerFirst(a[i]);
                }
            }

            if (n % 2 == 0) {
                for (Object x : deq.toArray()) out.print(x + " ");
            } else {
                for (int i = 0; i < n; ++i) {
                    out.print(deq.getLast() + " ");
                    deq.removeLast();
                }
            }
        }

    }
}



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

int main(){
  string s, t;
  cin >> s >> t;
  int f = 0;
  for(int i = 0 ; i < s.size(); i++){
    char a  = s[0];
    for(int j = 0 ; j < s.size(); j++){
      s[j] = s[(j+1)%s.size()];
    }
    s[s.size()-1] = a;
    if(s == t) f = 1;
  }
  if(f) cout << "Yes"<< endl;
  else cout << "No" << endl;
}


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

using namespace std;

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

    int k = n/1.08;
    int l = k+1;

//    cout << (int)(k*1.08) << "  " << (int)(l*1.08) << '\n';
    if ((int)(k*1.08) == n) cout << k << '\n';
    else if ((int)(l*1.08) == n) cout << l << '\n';
    else cout << ":(" << '\n';

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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



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




int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 2);

	repn(i, N) cin >> A[i];

	A[0] = 0;
	A[N + 1] = 0;

	ll c = 0;

	repn(i, N + 1) c += abs(A[i] - A[i-1]);

	repn(i, N) {
		cout << c - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1])<<endl;
	}

	system("PAUSE");

}


Measured memory_bytes: 2296
import sys
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if n in [0,1]:
    print(1)
    sys.exit()
    
if not m == 0: lis = [int(input()) for x in range(m)]
else: lis = [-1]
val1 = 1
if 1 in lis: val2 = 0
else: val2 = 1

if lis[0] == 1 and len(lis) >= 2:
    flg = lis[1]
    nex = 1
else:
    flg = lis[0]
    nex = 0
#print(lis)
for x in range(2,n):
    if x == flg: #x in lis
        #print(flg)
        nex += 1
        try: flg = lis[nex]
        except:flg = 0
        now = 0
    else:
        now = (val1 + val2) % mod
    val1,val2 = val2,now
    
print((val1 + val2) % mod)


Measured memory_bytes: 7088
N = int(input())
a = list(map(int, input().split()))
answer = 0
# def prime_decomposition(n):
#   i = 2
#   table = []
#   while i * i <= n:
#     while n % i == 0:
#       n /= i
#       table.append(i)
#     i += 1
#   if n > 1:
#     table.append(n)
#   return table
def count2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count  

for ai in a:
    # print(prime_decomposition(ai))
    # print(prime_decomposition(ai).count(2))
    answer += count2(ai)

print(answer)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  int A=(N/1000)%10;
  int B=(N/100)%10;
  int C=(N/10)%10;
  int D=N%10;
  char op1, op2, op3;
  if(A+B+C+D==7){
    op1='+';
    op2='+';
    op3='+';
  }
  else if(A+B+C-D==7){
    op1='+';
    op2='+';
    op3='-';
  }
  else if(A+B-C+D==7){
    op1='+';
    op2='-';
    op3='+';
  }
  else if(A-B+C+D==7){
    op1='-';
    op2='+';
    op3='+';
  }
  else if(A+B-C-D==7){
    op1='+';
    op2='-';
    op3='-';
  }
  else if(A-B+C-D==7){
    op1='-';
    op2='+';
    op3='-';
  }
  else if(A-B-C+D==7){
    op1='-';
    op2='-';
    op3='+';
  }
  else if(A-B-C-D==7){
    op1='-';
    op2='-';
    op3='-';
  }
  cout<<A<<op1<<B<<op2<<C<<op3<<D<<"="<<7<<endl;
}

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

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

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

int f(int x) {
  int res=0;
  while (x%2==0) {
    x/=2;
    res++;
  }
  return res;
}

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

  rep(i,n) {
    if (a[i]%2==1) {
      cout<<0<<endl;
      return 0;
    }
    a[i]/=2;
  }

  int t=f(a[0]);
  rep(i,n) {
    if (f(a[i])!= t) {
      cout<<0<<endl;
      return 0;
    }
    a[i]>>=t;
  }
  m>>=t;
  ll l=1;
  rep(i,n) {
    l=lcm(l,a[i]);
    if (l>m) {
      cout<<0<<endl;
      return 0;
    }
  }
  m/=l;
  int ans=(m+1)/2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(sys.stdin.readline())
A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
A = np.array(A, dtype=float) + np.diag([np.inf] * N)

useless = np.zeros((N, N), dtype=bool)
impossible = np.zeros((N, N), dtype=bool)
for via in range(N):
    # R[i][j]: i -> via -> j の距離
    R = sum(np.meshgrid(A[via], A[via]))
    useless |= R == A
    impossible |= R < A

if (impossible ^ np.eye(N, dtype=bool)).sum():
    print(-1)
else:
    print(int(A[~useless].sum() // 2))


Measured memory_bytes: 17860
fn main() {
    let v = read_vec::<i32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    yn(b - a == c - b);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int main() {
    int H,W;
    cin >> H >> W;
    char A[8][8];
    int cnt = 0;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            cin >> A[i][j];
            if(A[i][j] == '#') ++cnt;
        }
    }

    if(cnt == H + W - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
// C - Step
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N); rp(i, 0, N) cin>>A[i];
	int64_t s = 0, pre = A[0];
	rp(i, 1, N){
		if(pre > A[i]) s += pre - A[i];
		else pre = A[i];
	}
	cout<< s <<endl;
}


Measured memory_bytes: 4024
#include <stdio.h>

int main() {
  int N, i, count;
  char str[51];

  count = 0;
  scanf("%d", &N);
  scanf(" %s", str);
  for (i = 2; i < N; i++) {
    if (str[i] == 'C')
      if (str[i-1] == 'B')
        if (str[i-2] == 'A')
          count++;
  }
  printf("%d\n", count);
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string S;

    cin >> S;
    if( S[2] == S[3] && S[4] == S[5] ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int red = 0,white = 0;
	for(int i = 0; i < n;++i){
		if(s[i] == 'R')
			++red;
		else
			++white;
	}
	int ans = 0;
	for(int i = 0; i < red;++i){
		if(s[i] == 'W')
			++ans;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=(1LL<<61)-1;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end
ld eps=1e-9;
void solve(){
    int N;
    while((cin>>N,N)){
        vector<int> L(N);
        rep(i,N)cin>>L[i];
        vector<int> res(3);
        ld mn=1e18;
        rep(S,16)rep(A,16)rep(C,16){
            vector<int> R(N+1);
            R[0]=S;
            for(int i=1;i<=N;i++){
                R[i]=(R[i-1]*A+C)%256;
            }
            int ct[1<<8];
            memset(ct,0,sizeof(ct));
            rep(i,N)ct[(L[i]+R[i+1])%256]++;
            ld en=0;
            rep(j,1<<8)if(ct[j])en-=(ld)ct[j]/N*log((ld)ct[j]/N);
            if(en+eps<mn){
                mn=en;
                res={S,A,C};
            }
        }
        rep(i,3)if(i!=2)cout<<res[i]<<" ";else cout<<res[i];
        cout<<endl;
    }
}

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


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    char c;
    cin >> c;
    cout << (isupper(c) ? "A" : "a");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  string s; cin>>s;
  if (s=="Sunny") out("Cloudy");
  if (s=="Rainy") out("Sunny");
  cout<<"Rainy"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  ll a, b, k;
  cin >> a >> b >> k;

  if( b - a + 1 <= k ) {
    reps(i, a, b) {
      cout << i << endl;
    }
    return 0;
  }

  vl ans;
  rep(i, k) {
    ans.pb(a);
    ++a;
    ans.pb(b);
    --b;
  }

  sort(all(ans));

  rep(i, ans.size()) {
    if( ans[i] == ans[i+1] ) continue;
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
char a[55][55],b[55][55];
signed main(){
	ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int i=0;i<m;i++) for(int j=0;j<m;j++) cin>>b[i][j];
	for(int i=0;i+m<=n;i++){
		for(int j=0;j+m<=n;j++){
			bool check=1;
			for(int ii=0;ii<m;ii++)
				for(int jj=0;jj<m;jj++)
					if(a[i+ii][j+jj]!=b[ii][jj])
						check=0;
			if(check){
				cout<<"Yes";
				re 0;
			}	
		}
	}
	cout<<"No";
	re 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#define N 101


int main(){
  int i,j,num,num2,num3,num4[N][N],num5[N];
  
  scanf("%d",&num);
  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      num4[i][j] = 0;
    }
  }
  for(i=1;i<=num;i++){
    scanf("%d",&num5[i]);
    scanf("%d",&num2);
    if(num2 == 0)continue;
   

    else{
      for(j=0;j<num2;j++){
	scanf("%d",&num3);
	num4[i][num3] = 1;  
      }
    }
    
  }
  
  for(i=1;i<=num;i++){
    for(j=1;j<num;j++){
      printf("%d ",num4[i][j]);
    }
    printf("%d\n",num4[i][num]);
  }


  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#include<sstream>
#include<deque>
#include<iomanip>
#include<cctype>
#include<vector>
#include<utility>

#define F(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) x.begin(),x.end()

using namespace std;

string tos(int x)
{
	string xxxx="";
	int tx;
	tx=x;
	
	while(tx!=0)
	{
		xxxx+=tx%10;
		tx/=10;
	}
	
	reverse(all(xxxx));
	return xxxx;
}

bool pal(string lin)
{
	string xxx;
	xxx=lin;
	reverse(all(xxx));
	if(xxx==lin)return true;
	else return false;
}

int main(void)
{	
	int ans=0;
	int k1,k2;
	scanf("%d%d",&k1,&k2);
	
	F(i,k1,k2+1)
	{
		string str=tos(i);
		if(pal(str))ans++;
	}
	
	cout<<ans;
	return 0;
}

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

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

    int n, k;
    cin >> n >> k;
    long long ans = 0;
    vector<long long> h(n);
    for(int i = 0; i < n; i++) {
      cin >> h[i];
    }
    sort(h.begin(), h.end());
    if(n > k) {
      for(int i = 0; i < n - k; i++) {
        ans += h[i];
      }
    }else if(n <= k){
      ans = 0;
    }
    cout << ans << endl;
}

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

#define ll long long
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
  char s[100] = {'0'}; cin >> s;
  REP(i,100) {
    if ((i + 1) % 2) {
      if (s[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256