akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;
using ld = long double;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	FOR(i, 1, 3501){
		FOR(j, 1, 3501){
			ll a = i*j/gcd(i, j);
			ll b = a*N/gcd(a, N);
			ll c = b/i+b/j;
			ll d = 4*b/N-c;

			if(b > 0 && d > 0 && b%d == 0){
				cout << i << " " << j << " " << b/d << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (500010)

using namespace std;

int a[N][27],b[20][N],n,Q;
char s[N];

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

int main(){
  scanf("%s",s+1),n=strlen(s+1),Q=gi();
  for (RG int i=n;i;--i){
    a[i][s[i]-'a']=i+1;
    for (RG int j=s[i]-'a'+1;j<=26;++j) a[i][j]=a[a[i][j-1]][j-1];
    for (RG int j=0;j<s[i]-'a';++j) a[i][j]=a[a[i][26]][j]; b[0][i]=a[i][26];
  }
  for (RG int j=1;j<20;++j) for (RG int i=1;i<=n;++i) b[j][i]=b[j-1][b[j-1][i]];
  while (Q--){
    RG int l=gi(),r=gi()+1;
    for (RG int j=19;j>=0;--j) if (b[j][l] && b[j][l]<=r) l=b[j][l];
    puts(l==r ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 92928
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0){ break; }
		int cnt = N * (N + 1) / 2;
		vector<ll> b(cnt);
		ll smallestOdd = 0x7fffffffffffffffll;
		for(int i = 0; i < cnt; ++i){
			cin >> b[i];
			if(b[i] % 2 == 1){ smallestOdd = min(smallestOdd, b[i]); }
		}
		ll a0 = 0;
		for(int i = 0; i < cnt; ++i){
			if(b[i] % 2 == 0){ a0 = ((a0 == 0) ? b[i] : gcd(a0, b[i])); }
		}
		vector<ll> a;
		for(int i = 0; i < cnt; ++i){
			if(b[i] % 2 == 0){ a.push_back(b[i] / a0); }
		}
		sort(a.begin(), a.end());
		ll mul = sqrt(smallestOdd / (a[0] * a[1]));
		cout << a0 / mul << endl;
		for(int i = 0; i < a.size(); ++i){
			cout << a[i] * mul;
			if(i != a.size() - 1){ cout << " "; }
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
	// "sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}


func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}


func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)

	list := make(map[int]struct{}, n)
	lines, _ := ReadLongLines(n)

	for i := range lines {
		args := strings.Split(lines[i], " ")
		command, _ := strconv.Atoi(args[0])
		x, _ := strconv.Atoi(args[1])

		switch command {
		case 0: //insert
			list[x] = struct{}{}
			con.Printf("%d\n", len(list))
		case 1: //find			
			_, ok := list[x]
			if ok {
				con.Println("1")
			} else {
				con.Println("0")
			}
		case 2: // delete
			delete(list, x)
		}
		
	}
}


Measured memory_bytes: 18468
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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() {
int k;string s;
cin>>k;
cin>>s;
if(s.size()<=k){cout<<s<<endl;return 0;}
else{cout<<s.substr(0,k)+"..."<<endl;}

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
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;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,H,W,w,h;
set<pair<int,int>> s;
map<pair<int,int>,int> M;

void solve() {
    cin>>H>>W>>N;
    REP(i,N) {
        cin>>h>>w;
        w--;h--;
        M[{h,w}] = 1;
        REP(i,3)REP(j,3) {
            int nh = h-i, nw = w-j;
            if (nh<0||nw<0||nh>=H-2||nw>=W-2) continue;
            s.insert({nh,nw});
        }
    }
    int ans[10] = {(H-2)*(W-2)};
    for (auto p:s) {
        int cnt = 0;
        REP(i,3)REP(j,3) {
            cnt += M[{p.first+i,p.second+j}];
        }
        ans[cnt]++;
        ans[0]--;
    }
    REP(i,10) { _PN(ans[i]) } ;
}



Measured memory_bytes: 216028
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<int, int> P;

vector<P> rel;
bool used[4][4];

int dfs(int card){
  int ans = 0;
  if(card == 0) return 1;
  
  int x, y;
  
  for(int i = 0 ; i < 4 ; i++){
    for(int j = 0 ; j < 4 ; j++){
      if(used[i][j]) continue;
      x = j, y = i;
      goto TO;
    }
  }
 TO:;
  used[y][x] = true;
  
  for(int i = 0 ; i < 4 ; i++){
    int nx = x + rel[i].first, ny = y + rel[i].second;
    if(nx < 0 || nx > 3 || ny < 0 || ny > 3) continue;
    if(used[ny][nx]) continue;
    
    used[ny][nx] = true;
    ans += dfs(card-1);
    used[ny][nx] = false;
  }
  used[y][x] = false;
  return ans;
  /*
  for(int i = 0 ; i < 4 ; i++){
    for(int j = 0 ; j < 4 ; j++){
      if(used[i][j]) continue;
      used[i][j] = true;
      for(int k = 0 ; k < 4 ; k++){
	int nx = j + rel[k].first, ny = i + rel[k].second;
	if(nx < 0 || nx > 3 || ny < 0 || ny > 3) continue;
	if(used[ny][nx]) continue;
	used[ny][nx] = true;
	ans += dfs(card-1);
	used[ny][nx] = false;
      }
      used[i][j] = false;
    }
  }
  return ans;
  */
}

int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4){
    memset(used, false, sizeof(false));
    rel.clear();
    rel.push_back(P(x1, y1));
    rel.push_back(P(x2, y2));
    rel.push_back(P(x3, y3));
    rel.push_back(P(x4, y4));
  
    int ans = dfs(8);
    
    cout << ans << endl;
  }
  return 0;
}

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

int gcd(int x,int y){
    if (!y) return x;
    return gcd(y,x%y);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    ll ans=0;
    for (int i=1;i<=K;++i)
        for (int j=1;j<=K;++j)
            for (int k=1;k<=K;++k)
                ans+=gcd(i,gcd(j,k));
    cout << ans << '\n';
}

Measured memory_bytes: 3652
#include<stdio.h>

long long int len(char *str){
	long long int i,count=0;
	for(i=0;str[i]!='\0';i++){
		count++;
	}
	return count;
}
	
int main()
{
	char a[100000],b[100000],c[100000];
	scanf("%s%s%s",a,b,c);
	
	int x,y;
	x=len(a);
	y=len(b);
	
	if(a[x-1]==b[0] && b[y-1]==c[0]) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}


Measured memory_bytes: 128
h,w = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(10)]
li = [list(map(int,input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if lis[i][j] > lis[i][k] + lis[k][j]:
                lis[i][j] = lis[i][k] + lis[k][j]
ans = 0
for i in range(h):
    for num in li[i]:
        if num >= 0:
            ans += lis[num][1]
print(ans)

Measured memory_bytes: 3444
N = int(input())
A = list(map(int, input().split()))

A.sort()

cum = [A[0]]
for i in range(1,N):
    cum.append(cum[-1]+A[i])

for i in reversed(range(N-1)):
    if cum[i] * 2 >= A[i+1]:
        continue
    else:
        print(N-1-i)
        break
else:
    print(N)

Measured memory_bytes: 14320
import math
a, b, x  = map(int, input().split())

if x > a*a*b/2:
    tan_theta2 = (2*b)/a - (2*x)/a**3
    theta2 = math.degrees(math.atan(tan_theta2))
    print(theta2)
else:
    tan_theta = 2*x/(a*(b**2))
    theta = math.degrees(math.atan(tan_theta))
    print(90 - theta)


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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 6010;

int n, c;
char S[N];
int posa[N], to[N];
bool vis[N];
string dp[N];

int main() {

	scanf("%d%s", &n, S + 1);
	For(i, 1, 2 * n) if (S[i] == 'a') posa[++c] = i;
	c = 0;
	For(i, 1, 2 * n) if (S[i] == 'b') to[i] = posa[++c], to[to[i]] = i;

	Forr(i, 2 * n, 1) {
		if (to[i] > i) {
			if (S[i] == 'a') dp[i] = string("a") + 'b' + dp[to[i]];
			else {
				int r = to[i];
				memset(vis, 0, sizeof vis);
				vis[i] = vis[r] = true;
				For(j, i + 1, r) if (S[j] == 'b') {
					vis[j] = vis[to[j]] = true;
					r = to[j];
				}
				For(j, i, r) if (vis[j]) dp[i] += S[j];
				dp[i] += dp[r + 1];
			}
		}
		dp[i] = max(dp[i], dp[i + 1]);
	}

	cout << dp[1] << endl;

	return 0;
}

Measured memory_bytes: 14720
import java.util.Scanner;

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

              while(true){

                 int h =scan.nextInt();
                 int w =scan.nextInt();


                 if(h==0&&w==0){
                 break;
                 } else {

                   for(int h1 =0;h1<h;h1++){

                    for(int w1 =0;w1<w;w1++){

                       int i =h1+w1;

                       if(i%2==0){
                       System.out.print("#");
                       }

                       if(i%2==1){
                       System.out.print(".");
                       }
                    }
                     System.out.println();
                   }
                      System.out.println();
                   }
              }
        }
     }



Measured memory_bytes: 35468
#include<iostream>
#include<string>
using namespace std;
string in;
bool func(string &, int, int);
void add(string&, char, int,int&);
void rem(string&,int&);
int main() {
	cin >> in;
	string str;
	str = in[0];
	func(str, 1, in[0] - '0');
	return 0;
}

bool func(string&str, int place, int num) {
	if (place == 4) {
		if (num == 7) {
			str += "=7";
			cout << str << endl;
			return true;
		}
		else {
			return false;
		}
	}
	add(str, '+', place, num);
	if (func(str, place + 1, num)) {
		return true;
	}
	rem(str,num);
	add(str, '-', place, num);
	if (func(str, place + 1, num)) {
		return true;
	}
	rem(str, num);
	return false;
}

void rem(string&str,int& num) {
	if (str[str.size() - 2] == '+') {
		num -= str.back() - '0';
	}
	else {
		num += str.back() - '0';
	}
	for (int i = 0; i < 2; ++i) {
		str.pop_back();
	}
}

void add(string &str, char key, int place,int&num) {
	str += key;
	str += in[place];
	if (key == '+') {
		num += in[place] - '0';
	}
	else {
		num -= in[place] - '0';
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string S;
	cin >> S;
	if(S.size() == 3) reverse(all(S));
	Cout(S);
}


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

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

int main() {
  long long K;
  long long sum = 0;
  cin >> K;

  for (long long i = 1; i <= K; i++) {
    for (long long j = 1; j <= K; j++) {
      for (long long k = 1; k <= K; k++) {
        sum += gcd(gcd(i, j), k);
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9+1;

// a < b < cのとき
// a + b > c だけ判定すればよい

// i と j　を選んでai+bjでにぶたん ai+bjよりも小さくabs(ai-bj)よりも大きいのをにぶたん
//                                間にaiとbjがあったらそれぞれ除外

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    sort(L.begin(),L.end());
    
    ll res = 0;
    
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            auto rb = lower_bound(L.begin()+j,L.end(), L[i]+L[j]);
            auto lb = lower_bound(L.begin()+j,L.end(),abs(L[i]-L[j])+1);
            if (lb - L.begin() <= j) {
                res += max(0, (int)(rb-L.begin()) - (j+1));
            } else {
                res += rb - lb;
            }
            //cout << "i: " << i << "j: " << j << " " << *lb << " " << *rb << "rb-lb" << rb - lb << endl;
            //cout << res << endl;
            //res += rb - lb;
            //int r = rb - L.begin(), l = lb - L.begin();
            //res += max(0,rb - min(j,l));
            //if (L[i] > *lb && L[i] < *rb) res--;
            //if (L[j] > *lb && L[j] < *rb) res--;
        }
    }

    cout << res << endl;


}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define xx exit(0)
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#define ct continue
#define br break
#define rt return
using namespace std;
struct st{
	
};
bool cmp(){
	return 1;
}
void recur(){
	
}
int ham(string s,string t){
	int ss=s.size();
	int ans=0;
	for (int i=0; i<ss; i++){
		ans+=(s[i]!=t[i]);
	}
	return ans;
}
void solve(){
	string s,t;
	getline(cin,s);
	getline(cin,t);
	int ans=1e9;
	for (int i=0; i<=s.size()-t.size(); i++){
		int d=ham(s.substr(i,t.size()),t);
		ans=min(ans,d);
	}
	cout<<ans;
	
	
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while (t--) solve();
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;




int main(){
    LL a,b;cin>>a>>b;
    int k;cin >>k;
    for (int i = 0; i < k; i++) {
        if(i%2==0){
            b+=a/2;
            a/=2;
        }
        else{
            a+=b/2;
            b/=2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}



Measured memory_bytes: 256
import collections

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


class UnitDict(dict):

    def __init__(self, iterable=None, wrapper=lambda x: x):
        super().__init__(self)
        self.wrapper = wrapper
        if iterable is not None:
            self.update(iterable)

    def __missing__(self, key):
        self[key] = self.wrapper(key)
        return self[key]


class UnionFind(object):

    def __init__(self, nodes=None):
        self.par = UnitDict(wrapper=lambda x: x)
        self.rank = collections.defaultdict(int)
        self.groups = UnitDict(wrapper=lambda x: {x})
        if nodes is not None:
            for node in nodes:
                _, _, _ = self.par[node], self.rank[node], self.groups[node]

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def are_same(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def elements(self, node):
        return self.groups[self.root(node)]

    def size(self, node):
        return len(self.elements(node))

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.groups[x].update(self.groups[y])
            self.groups[y].clear()
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def grouper(self):
        roots = [x for x in self.par.keys()]
        groups = []
        for root in roots:
            if list(self.elements(root)) not in groups:
                groups.append(list(self.elements(root)))
        return groups


islands = UnionFind(range(1, N))
ans_list = []
last = int(N * (N-1) / 2)
ans_list.append(last)
for i in range(1, M):
    if islands.are_same(AB[-i][0], AB[-i][1]):
        ans_list.append(ans_list[-1])
    else:
        ans_list.append(ans_list[-1]-islands.size(AB[-i][0])*islands.size(AB[-i][1]))
    islands.unite(AB[-i][0], AB[-i][1])

for i in range(1, len(ans_list)+1):
    print(ans_list[-i])

Measured memory_bytes: 148088
n = int(input())
s = input()
#先頭から見て行って、000~999を含むかを確かめる
# strに直して、あったら次の文字にいく
ans = 0
for i in range(1000):
  num = str(i).zfill(3)
  pos = 0
  for j in range(n):
    if num[pos] == s[j]:
      pos += 1
      if pos == 3: 
        ans += 1
        break
print(ans)

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

int n, x;
vector <int> a;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    if(a%3 && b%3 && (a+b)%3) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int a,b;
    cin>>a>>b;
    if(a+b==15)
        cout<<"+"<<"\n";
    else if(a*b==15)
        cout<<"*"<<"\n";
    else
        cout<<"x"<<"\n";
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll n; cin>>n;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    vector<ll> v;
    for(ll i=2; i*i<=n; i++){
        if(n%i!=0) continue;
        ll q=1;
        while(n%i==0){
            n/=i;
            q*=i;
        }
        v.push_back(q);
    }
    if(n>1) v.push_back(n);
    if(v[0]%2==0) v[0]*=2;
    int m=v.size();
    ll ans=1e18;
    for(int i=0; i<(1<<m); i++){
        vector<ll> r(m);
        for(int j=0; j<m; j++){
            if(i&(1<<j)) r[j]=v[j]-1;
        }
        auto yz=crt(r, v);
        if(yz.first==0) ans=min(ans, yz.second);
        else ans=min(ans, yz.first);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
 char array[100][100];
int main() {
  int h,w,c,row,col;
  cin>>h>>w;
  for(int row=0;row<h;row++){
    for(int col=0;col<w;col++){
       cin>>array[row][col];
    }
  }
  for(int row=0;row<h;row++){
     for(int col=0;col<w;col++){
       cout <<array[row][col];
     }
     cout <<endl;
     for(int col=0;col<w;col++){
       cout <<array[row][col];
     }
     cout<<endl;

  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int n,a[200000];

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
    }
    int l = 0,r = n+1;
    while(r-l > 1) {
        int m = (l+r)/2;
        bool f = true;
        int c = 0;
        for(int i = 1;i <= m;i++) {
            while(c < n && a[c] != i) c++;
            if(c == n) f = false;
        }
        if(f) l = m;
        else r = m;
    }
    cout << (l ? n-l : -1) << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math","-fno-stack-protector")
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
const int MOD=1e9+7;
#define SZ 666666
int d,c[26],s[999][26],g[999],g_[999];
int f()
{
	int lp[26];
	memset(lp,0,sizeof lp);
	int ans=0;
	for(int i=1;i<=d;++i)
	{
		assert(g[i]>=0&&g[i]<26);
		int u=i-lp[g[i]];
		ans+=s[i][g[i]]-c[g[i]]*u*(u-1)/2;
		lp[g[i]]=i;
	}
	for(int j=0;j<26;++j)
	{
		int u=d+1-lp[j];
		ans-=c[j]*u*(u-1)/2;
	}
	return ans;
}
int main()
{
	srand(19260819);
	cin>>d;
	for(int i=0;i<26;++i) cin>>c[i];
	for(int i=1;i<=d;++i)
		for(int j=0;j<26;++j) cin>>s[i][j];
	for(int i=1;i<=d;++i) g[i]=i%26;
	ll of=f();
	int gc=0;
	while((++gc)%100!=0||clock()<CLOCKS_PER_SEC*1.8)
	{
		for(int i=1;i<=d;++i) g_[i]=g[i];
		int x=1;
//		if(rand()%2) x=rand()%(4*(rand()%3+1))+1;
		while(rand()%2) ++x;
		const int up=3;
		int cc=0;
		while(!cc) cc=rand()%(1<<up);
		while(x--)
		{
			int p=rand()%d+1;
			int u=up;
			while(!(cc&(1<<u))) u=rand()%up;
			if(u==0)
				g[p]=rand()%26;
			else if(u==1)
			{
				pii mx(-1,0);
				for(int x=0;x<26;++x)
					mx=max(mx,pii(s[p][x],x));
				g[p]=mx.se;
			}
		}
		{
			//cleanup!
			static int R[900][26],L[26];
			memset(L,0,sizeof L);
			for(int i=0;i<26;++i) R[d+1][i]=d+1;
			for(int i=d;i>=1;--i)
			{
				memcpy(R[i],R[i+1],sizeof R[i]);
				R[i][g[i]]=i;
			}
			for(int p=1;p<=d;++p)
			{
				pii mx(-2e9,0);
				for(int x=0;x<26;++x)
				{
					int u1=p-L[x],u2=R[p+1][x]-p;
					int dt=c[x]*(((u1+u2)*(u1+u2-1)-u1*(u1-1)-u2*(u2-1))/2)+s[p][x];
					mx=max(mx,pii(dt,x));
				}
				g[p]=mx.se;
				L[g[p]]=p;
			}
		}
		ll cf=f();
		if(cf<of)
		{
			for(int i=1;i<=d;++i) g[i]=g_[i];
		}
		else
		{
			if(of!=cf)
			cerr<<cf<<"\n";
			of=cf;
		}
	}
	for(int i=1;i<=d;++i)
		cout<<g[i]+1<<"\n";
	cerr<<of<<"\n";
	cerr<<clock()<<"ms  "<<gc<<"runs\n";
}


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

int main() {

  string s,t;
  cin >> s >> t;
  
  int a,b;
  cin >> a >> b;
  
  string u;
  cin >> u;
  
  if(u == s){
    a-=1;
    cout << a << " " << b;
  }
    
  if(u == t){
    b-=1;
    cout << a << " " << b;
  }
  
  
  
}

Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = parseInt(xs[0].split(' ')[0]);
   let K = parseInt(xs[0].split(' ')[1]);
   let p = xs[1].split(' ');
   const compare = (a, b)=>{ 
   return a - b;
   }
   p.sort(compare);
   let num = 0
   for(let i=0; i<K; i++){
     num += parseInt(p[i]);
   }
   console.log(num);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cerr.tie(NULL);

#define dbg(x) cerr << #x << " = " << x << ",  ";
#define vw(v)                        \
    cerr << endl                     \
         << endl                     \
         << (#v) << " is: " << endl; \
    for (ll B : (v))                 \
    {                                \
        cerr << B << " ";            \
    }                                \
    cerr << endl
#define check(x) cerr << "here " << (x) << "?" << endl

#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a) for (long long i = (a - 1); i >= 0; i--)

#define all(x) (x).begin(), (x).end()
#define rv(x) (x).rbegin(), (x).rend()
#define pb push_back

#define self_min(x, y) x = min(x, y)
#define self_max(x, y) x = max(x, y)

typedef long long ll;
ll const INF = 947483647, R_INF = 223372036854775807, MOD = 1e9 + 7;

const ll N = 1e5 + 5;

int main()
{
    FAST_IO
    ll n, target;
    cin >> n >> target;
    vector<pair<ll, ll>> v(n);
    for (auto &i : v)
        cin >> i.first >> i.second;

    vector<ll> DP(N, R_INF);
    DP[0] = 0;
    
    for (auto i : v)
        per(j, N)
            if (j - i.second >= 0)
                DP[j] = min(DP[j], DP[j - i.second] + i.first);
    
    per(i, N)
        if (DP[i] <= target)
            return cout << i, 0;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef long long ll;
// using i32=int;using i64=long long;using ll =i64;
// using uint=unsigned int;using ull=unsigned long long;
// template<typename T> using matrix=vector<vector<T> >;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

ll INF=1LL<<58;
class Main{
public:
	void run(){
		while(true){
			int N,K;scanf("%d %d",&N,&K);
			if(N==0)break;
			vector<int> as(N);REP(i,N)scanf("%d",&as[i]);

			vector<ll> imos(N+1);
			for(int v=1;v<=N;v++)imos[v]=imos[v-1]+as[v-1];

			ll Mv=-INF;
			for(int i=0;i<=N;i++){
				if(i+K<=N)Mv=max(Mv,imos[i+K]-imos[i]);
			}
			cout <<Mv<<endl;
		}
	}
};
int main(){
  	Main().run();
  	return 0;
 }

Measured memory_bytes: 2320
#include <stdio.h>

int main(){
    char s[10];
    scanf("%s",s);
    if (s[0]=='S')
    {
        printf("Cloudy");
        /* code */
    }
    else if (s[0] == 'C')
    {   
        printf("Rainy");
    }
    else
    {
        printf("Sunny");
    }
    
    
    
    return 0;


}

Measured memory_bytes: 128
#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() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll res = 1;
  rep(i, n) {
    if (a[i] % 2 == 0) {
      res *= 2;
    }
  }
  cout << pow(3, n) - res << endl;




  
  return 0;
}

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

using namespace std;
#define MAX 101
#define INFTY 10001

class Edge {
public:
    int source, target, cost;
    Edge(int source = 0,int target = 0,int cost = 0): source(source), target(target), cost(cost) {}
    bool operator < (const Edge &e) const {
        return cost < e.cost;
    }
};
bool visited[MAX], comp[MAX]; //restore cycle groups
int group[MAX];

int solve(std::vector<Edge> &G, int V, int r) {

    std::vector<Edge> mins(V, Edge(-1, -1, INFTY)); //minimum edges

    //target specified min search
    for (unsigned long i = 0; i < G.size(); i++) {
        const Edge &e = G[i];
        mins[e.target] = std::min(mins[e.target], e);
    }
    mins[r] = Edge(-1, r, 0);

    for (int i = 0; i < V; i++) {
        group[i] = 0;
        visited[i] = comp[i] = false;
    }

    int cnt = 0;
    for (int i = 0; i < V; i++) {
        if (!visited[i]) {
            int node = i;
            std::vector<int> path;
            while (node != -1 && !visited[node]) {
                visited[node] = true;
                path.push_back(node);
                node = mins[node].source;
            }

            bool isCycle = false;
            for (unsigned long i = 0; i < path.size(); i++) {
                int current = path[i];
                group[current] = cnt;
                if (current == node)
                    comp[cnt] = isCycle = true;
                if (!isCycle)
                    cnt++;
            }

            if (isCycle)
                cnt++;
        }
    }

    if (cnt == V) {
        int ans = 0;
        for(unsigned long i = 0;i < mins.size(); i++) {
            Edge &e = mins[i];
            ans += e.cost;
        }
        return ans;
    }

    int ans = 0;
    for (unsigned long i = 0; i < mins.size(); i++) {
        Edge &e = mins[i];
        if (comp[group[e.target]])
            ans += e.cost;
    }

    std::vector<Edge> G2;
    for (unsigned long i = 0; i < G.size(); i++) {
        const Edge &e = G[i];
        int source = group[e.source], target = group[e.target], cost = e.cost;
        if (source == target)
            continue;
        else
            G2.push_back(Edge(source, target, cost - (comp[target] ? mins[e.target].cost : 0)));
    }
    return ans + solve(G2, cnt, group[r]);
}

int main() {

    std::vector<Edge> G;
    int V, E, r, source, target, cost;
    std::scanf("%d %d %d", &V, &E, &r);
    for(int i = 0; i< E; i++) {
        std::scanf("%d %d %d", &source, &target, &cost);
        G.push_back(Edge(source, target, cost));
    }
    std::printf("%d\n", solve(G, V, r));
    return 0;
}




Measured memory_bytes: 3404
#include <stdio.h>

int main(void){
	int n;
	int b, f, r, v;
	int i, j, k, m;
	int room[5][4][11] = {0};

	scanf("%d", &n);

	for(i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);

		room[b][f][r] += v;
	}

	for(j = 0; j < 4; j++){
		for(k = 0; k < 3; k++){
			for(m = 0; m < 10; m++){
				printf(" %d", room[j + 1][k + 1][m + 1]);
			}
			printf("\n");

			if(k == 2 && j != 3){
				printf("####################");
				printf("\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

vector<tuple <ll,ll,ll>> z;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    ll p,y;
    rep(i,0,m){cin>>p>>y;z.pb(make_tuple(p,y,i));}
    sort(z.begin(),z.end());
    ll cnt=1;
    rep(i,0,m-1){
        ll a=get<0>(z[i]);
        ll b=get<0>(z[i+1]);
        get<1>(z[i])=cnt;
        if(a==b)cnt++;
        else cnt=1;
    }
    get<1>(z[m-1])=cnt;
    rep(i,0,m){
        ll a=get<0>(z[i]);
        ll b=get<1>(z[i]);
        ll c=get<2>(z[i]);
        get<2>(z[i])=b;
        get<1>(z[i])=a;
        get<0>(z[i])=c;
    }
    sort(z.begin(),z.end());
    rep(i,0,m){
        ll a=get<1>(z[i]);
        string aa=to_string(a);
        rep(i,0,6-aa.length())cout<<0;
        cout<<a;
        a=get<2>(z[i]);
        aa=to_string(a);
        rep(i,0,6-aa.length())cout<<0;
        cout<<a<<endl;
    }
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> m(n);
  rep(i, n) cin >> m[i];
  sort(m.begin(), m.end(), greater<int>());
  int buf = 101;
  int ans = 0;
  rep(i, n){
    if(m[i] < buf){
      ans += 1;
      buf = m[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
n = int(input())
a = list(map(int, input().split()))

ans = 1
zero = 0
for i in range(n):
    if a[i] == 0:
        zero += 1

if zero > 0:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > 1e+18:
        print(-1)
        exit(0)

print(ans)


Measured memory_bytes: 21644
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

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

    string dict = "abcdefghijklmnopqrstuvwxyz";

    int index = dict.find(C);

    cout << dict[index + 1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int K;
    cin >> K;
    vector<int> V(32);
    V[0] = 1;
    V[1] = 1;
    V[2] = 1;
    V[3] = 2;
    V[4] = 1;
    V[5] = 2;
    V[6] = 1;
    V[7] = 5;
    V[8] = 2;
    V[9] = 2;
    V[10] = 1;
    V[11] = 5;
    V[12] = 1;
    V[13] =2;
    V[14] = 1;
    V[15] = 14;
    V[16] =1;
    V[18] =1;
    V[17] = 5;
    V[19] = 5;
    V[20] = 2;
    V[21] = 2;
    V[22] = 1;
    V[23] = 15;
    V[24] = 2;
    V[25] = 2;
    V[26] = 5;
    V[27] = 4;
    V[28] = 1;
    V[29] = 4;
    V[30] = 1;
    V[31] = 51;
    cout << V[K-1] << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10**9 + 7
dp = [[0] * (k+1) for _ in range(n)]

for j in range(a[0] + 1):
    dp[0][j] = 1

for i in range(1, n):
    for j in range(k + 1):
        if j == 0:
            dp[i][j] = 1
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
            if j >= a[i] + 1:
                dp[i][j] -= dp[i-1][j-a[i]-1]
            dp[i][j] = dp[i][j] % mod

print(dp[-1][-1])


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(100000 + 2, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        int b;
        cin >> a >> b;
        for (int j = a; j <= b; ++j) {
            v[j] += 1;
        }
    }
    int max_{0};
    for (int i = 0; i < v.size(); ++i) {
        if (v[i] != 0 && (i - 1) <= v[i]) {
            max_ = i;
        }
    }
    if(max_ != 0) {
        cout << (max_ - 1) << endl;
    } else {
        cout << max_ << endl;
    }
}

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

int main(){
  int n, s = 0; scanf("%d", &n);
  priority_queue<int, vector<int>, greater<int>> p;
  rep(i, n){
    int a; scanf("%d", &a);
    s += a;
    if(a % 10 != 0) p.push(a);
  }
  if(s % 10 == 0){
    if(p.empty()) s = 0;
    else s -= p.top();
  }
  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = list(map(str, input().split()))

ans = 0

for i in range(N):
    if s[i] == 'Y':
        ans = 1
        break
# if a > b:

#
# print("Yes")
# print("No")
if ans == 1:
    print("Four")
else:
    print("Three")

Measured memory_bytes: 2940
//sobskdrbhvk
//remember the flying, the bird dies ):(
#include <bits/stdc++.h>

using namespace std;

typedef long long int LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

#define PB push_back
#define MP make_pair
#define L first
#define R second
#define sz(x) ((int)(x).size())
#define smax(x, y) ((x) = max((x), (y)))
#define smin(x, y) ((x) = min((x), (y)))
#define all(x) x.begin(),x.end()

const int maxn = 100;
string s[100];
bool mark[maxn][maxn];
int n, m;

void dfs(int i, int j){
	if(i >= n or j >= m or s[i][j] == '.') return;
	mark[i][j] = true;
	dfs(i + 1, j);
	dfs(i, j + 1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> s[i];
	dfs(0, 0);
	if(!mark[n - 1][m - 1]){
		cout << "Impossible\n";
		return 0;
	}
	int cnt = 0;
	for(int i = 0; i < n; i++)
		cnt += count(all(s[i]), '#');
	if(cnt != n + m - 1)
		cout << "Impossible\n";
	else
		cout << "Possible\n";
	return 0;
}

Measured memory_bytes: 764
main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = sum $ zipWith f xs ys
  where xs = take n s
        ys = take n $ reverse s
        n = length s `div` 2

f :: Char -> Char -> Int
f x y
   | x /= y    = 1
   | otherwise = 0


Measured memory_bytes: 380
#include<bits/stdc++.h>
#define MAX_N 55
using namespace std;
char mapp[MAX_N][MAX_N];
int n, m, cnt;
int dist[MAX_N][MAX_N];
struct node{
	int x, y;
}q[MAX_N*MAX_N];
bool pd[MAX_N][MAX_N];
const int r[]={1,-1,0,0}, w[]={0,0,1,-1};
inline void BFS(int sx, int sy){
	int hd, tl, dx, dy, fx, fy;
	hd=tl=1;
	q[1].x=sx;
	q[1].y=sy;
	while(hd<=tl){
		fx=q[hd].x;
		fy=q[hd].y;
		hd++;
		for(int i=0;i<4;++i){
			dx=fx+r[i];
			dy=fy+w[i];
			if(dx<1||dy<1||dx>n||dy>m||mapp[dx][dy]=='#'||pd[dx][dy]==1) continue;
			pd[dx][dy]=1;
			tl++;
			q[tl].x=dx;
			q[tl].y=dy;
			dist[dx][dy]=dist[fx][fy]+1;
			if(dx==n&&dy==m) return ;
		}
	}
}
int main(){
	memset(dist,127/3,sizeof dist);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			cin>>mapp[i][j];
			if(mapp[i][j]=='#') cnt++;
		}
	}
	dist[1][1]=1;
	pd[1][1]=1;
	BFS(1,1);
	int ans=n*m-cnt-dist[n][m];
	if(ans<0) puts("-1");
	else printf("%d",ans);
    return 0;
}





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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 410;
const int MM = 100010;

int N, M;
pii es[MM];
bool ng[MN];
bitset<MN> f[410];

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

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		es[i] = mp(x, y); 
	}

	rep(i, N) {
		f[i].set(i);

		for (int j = M-1; j >= 0; --j) {
			int x = es[j].fi;
			int y = es[j].se;
			if (!f[i][x] && !f[i][y]) {
				continue;
			}
			if (f[i][x] && f[i][y]) {
				ng[i] = 1;
				break;
			}
			f[i].set(x);
			f[i].set(y);
		}
	}

	int ret = 0;
	rep(i, N) if (!ng[i]) {
		rep(j, i) if (!ng[j]) {
			if (!(f[i] & f[j]).any()) {
				++ret;
			}
		}
	}
	cout << ret << endl;

 	return 0;
}

Measured memory_bytes: 1024
n, h = gets.strip.split.map(&:to_i)
a = readlines.map {|line| line.strip.split.map(&:to_i) }.sort

categorized = a.group_by(&:first)

usual = categorized[categorized.keys.max].sort.first
#a.delete(usual)

result = 0

a.select {|e| e.last>usual.first }.map(&:last).sort.reverse.each do |thr|
  h -= thr
  result += 1

  if h<=0
    p result
    exit
  end
end

result += 1 if h%usual.first > 0

result += (h/usual.first)

p result


Measured memory_bytes: 22888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  //四通りそのまま書く
  int x=sx,y=sy;
  rep(i,tx-sx)cout<<'R';
  rep(i,ty-sy)cout<<'U';
  rep(i,tx-sx)cout<<'L';
  rep(i,ty-sy)cout<<'D';
  cout<<'D';
  rep(i,tx-sx+1)cout<<'R';
  rep(i,ty-sy+1)cout<<'U';
  cout<<'L';
  cout<<'U';
  rep(i,tx-sx+1)cout<<'L';
  rep(i,ty-sy+1)cout<<'D';
  cout<<'R';
}

Measured memory_bytes: 256
let ext_euclid a b =
  let rec doit a b =
    if b = 0 then (1, 0, a)
    else
      let (x, y, d) = doit b (a mod b) in
      (y, x - (a / b) * y, d) in
  doit a b |> (fun (x, y, _) -> (x, y))

let () =
  let (a, b) = Scanf.scanf "%d %d\n" (fun a b -> (a, b)) in
  let (x, y) = ext_euclid a b in
  Printf.printf "%d %d\n" x y

Measured memory_bytes: 2420
package main

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

/* 一つ読み */
func scanText() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

/* 複数読み */
func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}
func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}
func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	a := scanSlice(n)

	for count := 0; true; count++ {
		for i := 0; i < n; i++ {
			if a[i]%2 == 1 {
				fmt.Println(count)
				return
			} else {
				a[i] = a[i] / 2
			}
		}
	}

}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    int ans = 0;
    for (int i = 1; i < N; ++i) {
        if (a[i] == a[i-1]) {
            a[i] = -1;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256