akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)1e6+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};
std::vector<int> factor(MAX2);
void gnerate()
{
	factor[1]=1;
	for(int i=2;i<MAX2;i++)
		factor[i]=i;

	for(int i=4;i<MAX2;i+=2)
		factor[i]=2;

	for(int i=3;i*i<MAX2;i++)
	{
		if(factor[i]==i)
		{
			for(int j=i*i;j<MAX2;j+=i)
			{
				if(factor[j]==j)
					factor[j]=i;
			}
		}
	}
}

int calculate(int n)
{
	if(n==1)
		return 1;

	int ans=1;

	int dup=factor[n];

	int c=1;
	int j=n/factor[n];

	while(j!=1)
	{
		if(factor[j]==dup)
			c+=1;
		else
		{
			dup=factor[j];
			ans=ans*(c+1);
			c=1;
		}

		j/=factor[j];
	}

	ans = ans*(c+1);
	return ans;
}

int main()
{
	fastio
	gnerate();
	int n;
	cin>>n;
	int res=0;
	for(int i=1;i<n;i++)
		res+=calculate(i);

	cout<<res<<endl;
}

Measured memory_bytes: 7072
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
using namespace std;

int main(){
 	int H,W;
  	cin >> H >> W;
  	vector<int> hh(H,0),ww(W,0);
  	vector< vector<char> > a(H,vector<char>(W));
  	for(int i = 0 ; i < H ; i ++){
     	for(int I = 0 ; I < W ; I ++){
         	cin >> a.at(i).at(I);
          	if(a.at(i).at(I) == '#'){
              hh.at(i)++;
              ww.at(I)++;
            }
        }
    }
  	for(int i = 0 ; i < H ; i ++){
     	for(int I = 0 ; I < W ; I ++){
          	if(ww.at(I) != 0 && hh.at(i) != 0) cout << a.at(i).at(I); 
        }
      	if(hh.at(i) != 0)cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, i, j=0;
	scanf("%d %d %d",&a,&b,&c);
	for (i = a; i <= b; i++){
		if (c%i == 0){
			j++;
		}
	}
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==0&&a%3!=0&&a%5!=0){
      cout<<"DENIED"<<endl;
      return(0);
    }
  }
  cout<<"APPROVED"<<endl;
  return(0);
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


int main() {
  ll N,M,a,b,c;
  cin >> N >> M;
  vector<vector<vector<ll>>> g(N);
  rep(i,M) {
    cin >> a >> b >> c;
    a--;b--;
    g[a].push_back({b,c});
    g[b].push_back({a,c});
  }

  int res=0;
  rep(i,N){
    priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>> pq;
    vector<ll> ans(N,LONG_LONG_MAX/100);
    pq.push({0,i});//cost、場所
    while (!pq.empty()) {
      auto t = pq.top();
      pq.pop();
      if (ans[t[1]]>t[0]){
        ans[t[1]] = t[0];
        for (auto e:g[t[1]]) {
          pq.push({t[0] + e[1] ,e[0]});
        }
      }
    }
    for (auto e:g[i]) {
      if (e[1]>ans[e[0]]) res++;
    }
  }
  cout << res/2 << endl;
}

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

int main(){
	int n,x;
	cin >> n >> x;
	vector<int> l(n+10);

	for (int i=1; i<=n; i++) cin >> l[i];

	int d = 0;
	int ans = 1;

	for (int i=2; i<=n+1; i++){
		d += l[i-1];
		if (d <= x) ans += 1;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
using namespace std;
 
int main(){
	int n;
	string s;
	cin >> s;
	for(int i = 0;i < 5;i++) cout << s[i];
	cout << " ";
	for(int i = 6;i < 13;i++) cout << s[i];
	cout << " " ;
	for(int i = 14;i < 19;i++) cout << s[i];
	cout << endl;
	return 0;	
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 137 B - One Clue
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/01
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

int32_t k;
int32_t coord_x;

void solve() {

    for (int i=-k+1;i<k;i++) {
        printf("%d ", coord_x+i);
    }

    printf("\n");

}

int main() {

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

    solve();

}


Measured memory_bytes: 3228
N = int(input())
dp = [[0 for _ in range(10)] for _ in range(10)]

def pair(n):
  num = str(n)
  p = int(num[0])
  s = n % 10
  return (p, s)


for i in range(1, N+1):
  pre, suf = pair(i)
  dp[pre][suf] += 1

ans = 0
for i in range(1, N+1):
  suf, pre = pair(i)
  ans += dp[pre][suf]

print(ans)

Measured memory_bytes: 3064
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
par=[-1]*n
def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True

def same(x,y):
  return find(x)==find(y)

def size(x):
  return -par[find(x)]

AB=[]
for i in range(m):
  AB.append(tuple(int(i)-1 for i in input().split()))
Ans=[n*(n-1)//2]
for i in range(m)[::-1]:
  a,b=AB[i]
  if same(a,b):
    Ans.append(Ans[-1])
  else:
    Ans.append(Ans[-1]-size(a)*size(b))
    unite(a,b)
Ans=Ans[::-1][1:]
for a in Ans:
  print(a)

Measured memory_bytes: 22948
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string x;
  cin >> x;

  int n = x.length();
  int ans = 0;
  rep(i, n) {
    if (x[i] == 'S') ans++;
    else {
      if (ans) ans--;
    }
  }
  cout << ans * 2 << '\n';





  
  return 0;
}

Measured memory_bytes: 720
N = int(input())
X = list(map(int, input().split()))

a = min(X)
b = max(X)
l = [0]*(b-a+1)
for i, p in enumerate(range(a, b+1)):
  for j in range(N):
    l[i] += (p - X[j])**2
print(min(l))

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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a, b) a = min((a),(b))
#define CHMAX(a, b) a = max((a),(b))
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
    int a, b;
    cin >> a >> b;
    auto ans = "Impossible";
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        ans = "Possible";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << (int)pow(2, (int)log2(n)) << endk;
  return 0;
}


Measured memory_bytes: 4120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
int X,A,B;

int main(){
  cin >> X >> A >> B;
  int ans=X-A+B;
  if(ans<=X){
    cout << "delicious" << endl;
  }
  else if(ans<=X+X)cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}


Measured memory_bytes: 256
# 壊れている床を無視すればフィボナッチ数になってる
from collections import defaultdict

def Fib(n, broken):
    dd = defaultdict(int)

    dd[0] = 1

    for i in range(n):
        for j in range(i+1, min(n, i+2)+1):
            if broken[j] == 0:
                dd[j] += dd[i]
                dd[j] %= 1000000007

    return dd[n]


n, m = map(int, input().split())
A = [int(input()) for _ in range(m)]
broken = defaultdict(int)
for c in A:
    broken[c] = 1

ans = Fib(n, broken)
print(ans % 1000000007)

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

ll N, K;
int MAX_DIGITS = 40;
vi digitCount (MAX_DIGITS);
vector<vll> dp (MAX_DIGITS, vll (2, -1));
vll nums;
ll recurse(int digitpos, bool less) {
    if (digitpos < 0) return 0;
    if (dp[digitpos][less] != -1) return dp[digitpos][less];

    // place 1
    ll best = 0;
    if (less || (K & (1LL << digitpos))) {
        best = max(best, (1LL << digitpos) * (N-digitCount[digitpos]) + recurse(digitpos - 1, less));
    }

    // place 0
    best = max(best, (1LL << digitpos) * digitCount[digitpos] + recurse(digitpos - 1, less | (K & (1LL << digitpos))));

    dp[digitpos][less] = best;
    return best;
}

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

    
    cin >> N >> K;

    nums.resize(N);

    F0R(i, N) {
        ll num; cin >> num;
        nums[i] = num;
        F0R(d, MAX_DIGITS) {
            digitCount[d] += num % 2;
            num /= 2;
        }
    }
    cout << recurse(39, false) << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var S = Read();
            var ans = S.Substring(0, K - 1);
            if (S[K - 1] == 'A')
            {
                ans += "a";
            }
            else if (S[K - 1] == 'B')
            {
                ans += "b";
            }
            else if (S[K - 1] == 'C')
            {
                ans += "c";
            }
            ans += S.Substring(K, N - K);

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    int D;
    D = max(max(A, B),C)*3 - (A+B+C);
    if (D%2 == 0) cout << D/2 << endl;
    else cout << D/2 + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    int count=1;
    for(int j=0;j<N-1;j++){
        if(a[j]!=a[j+1]){
            count = count + 1;
        }
    }
    cout<<count<<endl;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for (char c: s) {
        if (c == 'R') cnt++;
    }
    int b = n - cnt;
    bool ans = (cnt > b);
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int selectionSort(int A[],int N){
	int i,j,minj,tag;
	int ss=0;
	
	for(i=0;i<N-1;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		tag=A[i];
		A[i]=A[minj];
		A[minj]=tag;
		if(i!=minj){
			ss++;
		}
	}
	return ss;
}

int main(void){
	int N,ss,i;
	int A[100];
	
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	
	ss=selectionSort(A, N);
	
	for(i=0;i<N;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	
	printf("\n");
	printf("%d\n",ss);
	return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	if(a > 8 || b > 8)
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << "Yay!" << endl;
	}
	return 0;
}

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

int main(){

    vector<int> a(3);
    for(int i=0;i<3;i++) cin>>a.at(i);

    sort(a.begin(),a.end());

    cout<<abs(a.at(1)-a.at(0)+abs(a.at(2)-a.at(1)))<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, M, result = 0; cin >> N;
    map<string, int> S, T;
    rep (i, 0, N) {
        string in; cin >> in;
        if (S.count(in) == 0) S[in] = 1;
        else S[in]++;
    }
    cin >> M;
    rep (i, 0, M) {
        string in; cin >> in;
        if (T.count(in) == 0) T[in] = 1;
        else T[in]++;
    }

    for (auto n : S) result = max(result, n.second - T[n.first]);
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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

int main() {

	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N-1) {
		cin >> A[i];
		A[i]--;
	}

	vector<int> B(N,0);
	rep(i, N-1) {
		B[A[i]]++;
	}

	rep(i, N) {
		cout << B[i] << endl;
	}
}


Measured memory_bytes: 4464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int a,b,c;
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);

	gbtb;
	cin>>a>>b>>c;
	if(a==b&&b==c)
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }


    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#define MAX 1299709
#include <stdio.h>
#include <math.h>
int main(void) {
    int sieve[MAX+2]={0},num,p,pn,i,j,temp;
    for (i=2; i<=sqrt(MAX); i++) {
        if (sieve[i]==0) {
            for (j=2*i; j<=MAX; j+=i) {
                sieve[j]=1;
            }
        }
    }
    while (scanf("%d",&num)!=EOF&&num!=0) {
        if (sieve[num]==0) {
            p=num,pn=num;
        } else {
            temp=num;
            while (sieve[temp]==1) {
                temp--;
            }
            p=temp;
            temp=num;
            while (sieve[temp]==1) {
                temp++;
            }
            pn=temp;
        }
        printf("%d\n",pn-p);
    }
    return 0;
}

Measured memory_bytes: 5684
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int N,M,Q, L[200009],R[2000009], X[509][509], C[509][509];

int main(){
  
  cin >> N >> M >> Q;
  for(int i = 1; i <= M; i++){
    cin >> L[i] >> R[i]; X[L[i]][R[i]]++;
  }
  for(int i=1; i <= N; i++){
    for(int j=1; j <= N; j++) C[i][j] = C[i][j-1] + X[i][j];
  }
  for(int i = 1; i <= Q;i++){
    int p,q; cin >> p >> q;
    int sum = 0;
    for(int j=p; j <= q; j++) sum += C[j][q] - C[j][p-1];
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 7424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        if (a[0][0] == '.' || a[n - 1][m - 1] == '.') {
            out.println("Impossible");
            return;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) if (a[i][j] == '#'){
                if (i < n - 1 || j < m - 1) {
                    int r = 0;
                    if (i < n - 1 && a[i + 1][j] == '#') r++;
                    if (j < m - 1 && a[i][j + 1] == '#') r++;
                    if (r != 1) {
                        out.println("Impossible");
                        return;
                    }
                }
                if (i > 0 || j > 0) {
                    int r = 0;
                    if (i > 0 && a[i - 1][j] == '#') r++;
                    if (j > 0 && a[i][j - 1] == '#') r++;
                    if (r != 1) {
                        out.println("Impossible");
                        return;
                    }
                }
            }
        }
        out.println("Possible");
    }


    private BufferedReader br;
    private PrintWriter out;
    private StringTokenizer st;

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

}


Measured memory_bytes: 8148
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 9;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int h, w, c, ans;
const int limit = 5;
vector<vector<int>> board(MAX_N, vector<int>(MAX_N));
bool used[MAX_N][MAX_N];
bool isOK(int y, int x)
{
    if(y >= 0 and x >= 0 and y < h and x < w) return true;
    return false;
}
int calc()
{
    int res = 0;
    int color = board[0][0];
    if(color != c) return 0;
    memset(used, 0, sizeof(used));
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    used[0][0] = true;
    while(que.size())
    {
        pair<int, int> now = que.front(); que.pop();
        res++;
        for(int i = 0; i < 4; i++)
        {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];
            if(not isOK(ny, nx)) continue;
            if(used[ny][nx] || board[ny][nx] != color) continue;
            used[ny][nx] = true;
            que.push(make_pair(ny, nx));
        }
    }
    return res;
}
void change(int next_color)
{
    int color = board[0][0];
    memset(used, 0, sizeof(used));
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    used[0][0] = true;
    while(que.size())
    {
        pair<int, int> now = que.front(); que.pop();
        board[now.first][now.second] = next_color;
        for(int i = 0; i < 4; i++)
        {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];
            if(not isOK(ny, nx)) continue;
            if(used[ny][nx] || board[ny][nx] != color) continue;
            used[ny][nx] = true;
            que.push(make_pair(ny, nx));
        }
    }
}
void dfs(int cnt)
{
    if(cnt == limit)
    {
        ans = max(ans, calc());
        return;
    }
    vector<vector<int>> tmp = board;
    for(int color = 1; color <= 6; color++)
    {
        if(board[0][0] == color) continue;
        change(color);
        dfs(cnt + 1);
        board = tmp;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> h >> w >> c, h | w | c)
    {
        ans = -1;
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                cin >> board[i][j];
            }
        }
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3144
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<unordered_map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<memory>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)   a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll s; cin >> s;
    
    v<> x ={0,(ll)1e9,INF};
    v<> y ={0,1,INF};
    ll v=(ll)1e9;
    
    x[2]=(v-s%v)%v;
    y[2]= (x[2]+s)/v;
    

    rep(i,3){
        cout << x[i] << " "<<y[i]<<" ";
    }
}

int main(){
    a();
}

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


     Scanner stdIn = new Scanner(System.in);
     int[] a = new int[3];
     for (int i = 0; i < 3; i++) {
    	 a[i] = stdIn.nextInt(); }
     Arrays.sort(a);
     System.out.println(a[0] + " " + a[1] + " " + a[2]);





}
}



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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380
//......###
int main() {
    int N;
    string s;
    cin >> N >> s;
    int l = s.size();
    int cwl[200001];
    int cbr[200001];
    FOR(i, 1, l + 1) {
        cwl[i] = cwl[i - 1];
        if(s[i - 1] == '#')
            cwl[i]++;

        cbr[i] = cbr[i - 1];
        if(s[l - i] == '.')
            cbr[i]++;
    }
    int ma = INF;
    REP(i, l + 1) { chmin(ma, cwl[i] + cbr[l - i]); }
    cout << ma;
    return 0;
}

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

#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
void solve(){
	int n, k, x, y;
	cin>>n>>k>>x>>y;
	cout<<min(n,k)*x+max(0, n-k)*y<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//    cin>>t;
    while(t--){
        solve();
    }
    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();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    }
}

Measured memory_bytes: 62920
am = 'AMBIGUOUS'
ym = 'YYMM'
my = 'MMYY'
na = 'NA'

s = input()

def isM(ss):
  return 1 <= int(ss) <= 12

def isY(ss):
  return 0 <= int(ss) <= 99

def isYM(ssss):
  return isY(ssss[0:2]) and isM(ssss[2:4])

def isMY(ssss):
  return isM(ssss[0:2]) and isY(ssss[2:4])

print(am if isYM(s) and isMY(s) else ym if isYM(s) else my if isMY(s) else na)

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

#define MAX 250

using namespace std;

int n,q;
int n_lst[MAX],q_lst[MAX];

bool bf(int idx,int x){
    if(x == 0) return true;
    if(idx < n){
        return bf(idx+1,x) || bf(idx+1,x-n_lst[idx]);
    }
    return false;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++) cin >> n_lst[i];
    cin >> q;
    for(int i=0;i<q;i++) cin >> q_lst[i];

    for(int i=0;i<q;i++){
        if(bf(0,q_lst[i]))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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 <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    int n,k;
    ll sum=1;
    cin>>n>>k;
    ll l=0,r=n;
    
    REP(i,1,n+1){
        if(i>=k)sum=(sum+(r-l)+1)%INF;
        l+=i;
        r+=(n-i);
        //cout<<sum<<" "<<l<<" "<<r<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3632
import java.util.Scanner;

import static java.lang.Character.*;

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

        String input = sc.nextLine();

        char[] output = new char[input.length()];

        for(int i = 0; i < input.length(); i++){
            if(isLowerCase(input.charAt(i)))
                output[i] = toUpperCase(input.charAt(i));
            else if(isUpperCase(input.charAt(i)))
                output[i] = toLowerCase(input.charAt(i));
            else output[i] = input.charAt(i);
        }

        System.out.println(output);

        sc.close();
    }
}


Measured memory_bytes: 26292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n<=999) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl; 
}

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

int n;
int A[100000];

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

int main() {
    int q, t, result;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    result = 0;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &t);
        if (binarySearch(t)) {
            result++;
        }
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

bool cnk(int n, int k) {
	bool res = true;
	for (int i = 0; i < 30; ++i)
		if (!((1 << i) & n))
			res &= (!((1 << i) & k));
	return res;
}

void solve() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; ++i)
		s[i] -= '0';
	
	bool f1, f2;
	while (s.size() > 1) {
		string t(s.size() - 1, 0);
		f1 = f2 = false;
		for (int i = 0; i < t.size(); ++i) {
			t[i] = abs(s[i] - s[i + 1]);
			f1 |= (t[i] == 1);
			f2 |= (t[i] == 2);
		}
		s = t;
		if (!f1 || !f2)
			break;
	}
	
	if (s.size() == 1) {
		cout << (int)s[0] << endl;
		return;
	}
	
	n = s.size();
	bool ans = false;
	for (int i = 0; i < n; ++i)
		if (cnk(n - 1, i))
			ans ^= (bool)s[i];
	
	cout << (ans ? (f1 ? 1 : 2) : 0) << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 3332
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

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

    int ans=0;
    for(int i=1;i<=n;i++){
        int nowval=a[i];
        if(nowval==-1)continue;
        if(a[nowval]==i){
            ans++;
            a[i]=-1;
            a[nowval]=-1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3736
a = [0]*4
n,a[1],a[2],a[3] = map(int,input().split())

l = []
for i in range(n):
  l += [int(input())]
  
Inf = 5000
  
def f(x):
  if len(x) == n:
    if not (1 in x and 2 in x and 3 in x):
      return Inf
    b = [0]*4
    c = -30
    for i in range(n):
      t = x[i]
      if t > 0:
        b[t] += l[i]
        c += 10
    for i in range(1,4):
      c += abs(a[i]-b[i])
    return c
  else:
    return min(f(x+[0]),f(x+[1]),f(x+[2]),f(x+[3]))
  
print(f([]))

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

int main() {

	string s; cin >> s;
	int r_cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') r_cnt++;
	}
	int ans;
	if (r_cnt == 0) ans = 0;
	else if (r_cnt == 1) ans = 1;
	else if (r_cnt == 3) ans = 3;
	else {
		if (s[1] == 'R') ans = 2;
		else ans = 1;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  string x;
  cin >> x;
  int len = (int(x.length()));
  cout << string(len, 'x') << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=(ll)(1e18);

int main()
{
    ll a,b,c,k,d,e,f,n,m,t;
    cin>>n;
    ll ch[n+5][3];
    //ll dp[n+5][3];
    
        cin>>ch[0][0]>>ch[0][1]>>ch[0][2];
    for(int i=1;i<n;i++)
    {
        cin>>ch[i][0]>>ch[i][1]>>ch[i][2];
        ch[i][0]+=max(ch[i-1][1],ch[i-1][2]);
        ch[i][1]+=max(ch[i-1][2],ch[i-1][0]);
        ch[i][2]+=max(ch[i-1][0],ch[i-1][1]);
    }
    
    
    
    
    cout<<(max(ch[n-1][0],max(ch[n-1][1],ch[n-1][2])));
    //cout<<"099";
    
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main ()
{
	int i,n;
	long long int k=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0 && i%15!=0)
		{
			k=k+i;
		}
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<int,int>
int N, D, X;
int A[110];
int main() {
	std::cin >> N >> D >> X;
	for (int i = 1; i <= N; i++) {
		int tmp;
		std::cin >> tmp;
		X += (D - 1) / tmp;
		X++;
	}
	std::cout << X << std::endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    sum_score = m + f
    if m != -1 and f != -1:
        if sum_score >= 80:
            print("A")
        elif 65 <= sum_score < 80:
            print("B")
        elif 50 <= sum_score < 65:
            print("C")
        elif 30 <= sum_score < 50:
            if r >= 50:
                print("C")
            else:
                print("D")
        else:
            print("F")
    else:
        if m == -1 and f == -1 and r == -1:
                break
        else:
            print("F")



Measured memory_bytes: 5592
#include <iostream>
using namespace std;
int main() {
    long long int a, b, k, tk, ao;
    cin >> a >> b >> k;
    if (a > k) {
        tk = a - k;
        ao = b;
    }
    else {
        tk = 0;
        ao = b - (k - a);
    }
    if (ao < 0) {
        ao = 0;
    }
    cout << tk << ' ' << ao;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    string x;
    cin>>n;
    Vs vs(n);
    Vec t(n);
    rep(i,n){
        cin>>vs[i]>>t[i];
    }
    cin>>x;

    ll ans=0;

    bool add = false;
    rep(i,n){
        if(add){
            ans += t[i];
        }
        if(vs[i]==x){
            add = true;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000000000000005LL
#define MOD 1000000007

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

ll N;
ll A[55];

bool check(ll K){
	ll u = 0;
	rep(i,0,N){
		ll b = A[i]+K;
		if(b<=N-1)continue;
		u += b/(N+1LL);
		b %= N+1LL;
		if(b == N) u++;
	}
	return (K >= u);
}


int main()
{
	cin >> N;
	rep(i,0,N)cin >> A[i];
	ll l=-1,r=INF;
	while(r-l>1){
		ll m = (l+r)/2;
		if(check(m))r = m;
		else l = m;
	}
	ll k = r;
	rep(i,0,10000){
		ll li = (ll)i;
		ll t = r - li;
		if(t < 0)break;
		if(check(t))k = t;
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int N=1e8+7;

int a[200]={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};
int main()
{
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 2e5 + 5;

int n,k,c,a[N],b[N];
string s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k>>c>>s;
	int cnt=0;
	for(int i=0;i<s.size()&&cnt<k;i++){
		if(s[i]=='o'){
			cnt++;
			a[i]=cnt;
			i+=c;
		}
	}
	cnt=0;
	for(int i=s.size()-1;i>=0&&cnt<k;i--){
		if(s[i]=='o'){
			cnt++;
			b[i]=cnt;
			i-=c;
		}
	}
	for(int i=0;i<s.size();i++){
		if(a[i]!=0&&b[i]!=0&&a[i]+b[i]==k+1) cout<<i+1<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3348
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	INF := int(math.Pow10(10))
	N, M, L := scanInt(), scanInt(), scanInt()

	d := make([][]int, N)
	for i := 0; i < N; i++ {
		d[i] = make([]int, N)
		for j := 0; j < N; j++ {
			if i == j {
				d[i][j] = 0
			} else {
				d[i][j] = INF
			}
		}
	}

	for i := 0; i < M; i++ {
		a, b, c := scanInt(), scanInt(), scanInt()
		if c <= L {
			d[a-1][b-1] = c
			d[b-1][a-1] = c
		}
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				d[i][j] = int(math.Min(float64(d[i][j]), float64(d[i][k]+d[k][j])))
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if d[i][j] == 0 {
				d[i][j] = 0
			} else if d[i][j] <= L {
				d[i][j] = 1
			} else {
				d[i][j] = INF
			}
		}
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				d[i][j] = int(math.Min(float64(d[i][j]), float64(d[i][k]+d[k][j])))
			}
		}
	}

	Q := scanInt()
	ans := make([]int, Q)
	for i := 0; i < Q; i++ {
		s, t := scanInt(), scanInt()
		if dist := d[s-1][t-1]; dist >= INF {
			ans[i] = 0
		} else {
			ans[i] = dist
		}
	}

	for _, a := range ans {
		fmt.Println(a - 1)
	}
}


Measured memory_bytes: 4352
a[10]={63,6,91,79,102,109,125,39,127,111};
main(n,c,d,x,i){for(;scanf("%d",&n),~n;)for(c=0;n--;puts(""),c=a[x])for(scanf("%d",&x),c^=a[x],i=6;~i;i--)putchar(48+((c>>i)&1));exit(0);}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        
        long a = 1;
        
        for(long i = 1; i * i <= n; i++) {
            if(n % i == 0) {
                if(Math.abs(i - n/i) < Math.abs(a - n/a))
                    a = i;
            }
        }
        int cntA = 0;
        long A = a;
        while(A > 0) {
            cntA++;
            A /= 10;
        }
        
        int cntN = 0;
        long N = n/a;
        while(N > 0) {
            cntN++;
            N /= 10;
        }
		System.out.println(Math.max(cntN, cntA));
    }
    
}


Measured memory_bytes: 23892
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

BC = []
for i in range(M):
    Bi,Ci = map(int,input().split())
    BC.append([Bi,Ci])
BC.sort(key=lambda x : x[1],reverse=True)
now = 0
c = 0
b = 0
ans = 0
while now < N:
    if b == M:
        ans += A[now]
        now += 1
        continue
    if BC[b][0] == c:
        b += 1
        c = 0
    if b == M:
        ans += A[now]
        now += 1
        continue
    ans += max(A[now],BC[b][1])
    now += 1
    c += 1
print(ans)


Measured memory_bytes: 25656
N = int(input())
max_val = -1 * 10 ** 9
min_r = int(input())

for _ in  range(N - 1):
  R = int(input())
  val = R - min_r
  max_val = max(val, max_val)
  min_r = min(R, min_r)

print(max_val)


Measured memory_bytes: 5612