akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(void){
	int n;
	cin>>n;
	while(n--){
		int m,before;
		int mx=0,mn=0;

		cin>>m;
		cin>>before;

		while(m-- > 1){
			int now;
			cin>>now;
			mx = max(mx, now - before);
			mn = min(mn, now - before);
			before = now;
		}

		cout<<mx<<" "<<-mn<<endl;
	}

	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 12) {
		cout << b;
	}
	else if (a > 5) {
		cout << b / 2;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"debuglandınız\n";
ll int N,i,j,K;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> N >> K;
	vector<long long int> v(N),dp(N, 999999999);
	for(i=0;i<N;i++)cin>>v[i];
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	for(i=0;i<N;i++){
		for(j=1;j<=K;j++){
			if(i+j>=N)break;
			dp[i+j]=min(dp[i+j], dp[i]+abs(v[i]-v[i+j]));
		}
	}
	cout<<dp[N-1];
	return 0;
}

Measured memory_bytes: 1792
while 1:
    n = int(input())
    m = int(input())
    if n == m == 0:
        break
    a = []
    for i in range(m):
        x, y = map(int,input().split())
        a.append([x, y])
    a.sort(key = lambda x: x[0])
    f1 = []
    f2 = []
    for i in range(m):
        if a[i][0] == 1:
            f1.append(a[i][1])
        elif a[i][0] in f1 and not (a[i][1] in f1) and not (a[i][1] in f2):
            f2.append(a[i][1])
        elif a[i][1] in f1 and not (a[i][0] in f1) and not (a[i][0] in f2):
            f2.append(a[i][0])
    print(len(f1) + len(f2))


Measured memory_bytes: 6916
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<ll>c(n - 1), s(n - 1), f(n - 1);
    REP(i, n - 1) {
        c[i] = in();
        s[i] = in();
        f[i] = in();
    }

    REP(i, n) {
        ll now = 0;
        for (ll j = i; j < n - 1; ++j) {
            now = max(
                now + (f[j] - now % f[j]) % f[j],
                s[j] + (f[j] - s[j] % f[j]) % f[j]
            ) + c[j];
        }
        cout << now << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
int N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	cin >> N;
	if (N < 10) {
		cout << N;
	}
	else {
		ans += 9;
		if (N < 1000) {
			ans += max(0 , N - 100 + 1);
			cout << ans;
		}
		else {
			ans += 900;
			ans += max(0, N - 10000 + 1);
			if (N == 100000) {
				ans--;
			}
			cout << ans;
		}
	}
}

Measured memory_bytes: 256
import sys
n,x=map(int,input().split())
l = list(map(int,input().split()))

d=0
cnt=0
for i in range(n):
    if d>x :
        print(cnt) 
        sys.exit()   
    else:
        d+=l[i]
        cnt+=1

if d>x:
    print(cnt)
else:
    print(n+1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll 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;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> vt(n);
  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    ll t;
    cin >> t;
    ans = lcm(ans, t);
  }

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

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
typedef long long ll; 
using namespace std; 
int main() { 
  string s;
  cin>>s; 
  bool f=true; 
  for(int i=0;i<s.length();i++){
    if(i%2==0){ 
      if(s.substr(i,1)!="h")f=false;
    }else{ if(s.substr(i,1)!="i")f=false; 
         }
  } 
  if(s.length()%2!=0)f=false;
  if(f){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
    } 
  return 0; 
} 



Measured memory_bytes: 3604
#include <stdio.h>

int main(){
  int arr,A[100],i,j=0,k,v;
  
  scanf("%d",&arr);
  for(i=1;i<=arr;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<=arr;i++){
    v = A[i];
    j = i-1;
    
    while(j > 0 && A[j] > v)
      {
	A[j+1] = A[j];
	j--;
      }
    
    A[j+1] = v;
    for(k=1;k<=arr;k++){
      if(k == arr)
	printf("%d\n",A[k]);
      else
	printf("%d ",A[k]);
    } 
  }
  
  return 0;
}


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

int solve(int n, int m, int x, vector<vector<int>>& a) {
    int ans = INT32_MAX;
    for (int i = 0; i < pow(2, n); i++) {
        vector<int> row(m, 0);
        int amt = 0;
        int j = i;
        int r = 0;
        while (j) {
            if (j & 1) {
                for (int k = 0; k < m; k++) {
                    row[k] += a[r][k + 1];
                }
                amt += a[r][0];
            }
            j >>= 1;
            r++;
        }

        bool inv = false;
        for (auto& item: row) {
            if (item < x) {
                inv = true;
                break;
            }
        }
        if (!inv) {
            ans = min(amt, ans);
        }
    }
    if (ans == INT32_MAX) {
        return -1;
    } else {
        return ans;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, x;
    cin >> n >> m >> x;

    vector<vector<int>> a(n, vector<int>(m + 1, 0));
    for (auto& row: a) {
        for (auto& item: row) {
            cin >> item;
        }
    }
    cout << solve(n, m, x, a) << "\n";
}


Measured memory_bytes: 4068
import heapq
n,k = map(int,input().split())
ab = [0]*n
lis = []
for i in range(n):
    a,b = map(int,input().split())
    lis.append([a,b])
lis.sort(key= lambda val : val[0])
c = 0
for a,b in lis:
    if k <= c+b:
        ans = a
        break
    else:
        c += b
print(ans)

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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k; cin >> n >> k;
	string s; cin >> s;
	/*if(k==2 || k==5){
		ll counter=1ll;
		rep(i,0,sz(s),1) if((s[i]-'0')%k == 0) ++counter;
		cout << (((counter-1)*counter)/2ll);
		exit(0);
	}*/
	if (10%k == 0) { // 2,5
    ll ans = 0;
    rep(r,0,n,1) {
      if ((s[r]-'0') % k == 0) {
        ans += r+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
	else{
		vector<ll> d(n+1, 0ll);
		ll mul = 1ll;
		map<ll, ll> mp;
		mp[0]++;
		for(int i=n-1; i>=0; --i){
			ll h = (s[i]-'0');
			d[i] = ((h*mul)+d[i+1])%k;
			mp[d[i]]++;
			mul*=10ll; mul%=k;
		}
		vector<int> cnt(k);
		ll ans = 0;
		for (int i = n; i >= 0; --i) {
			ans += cnt[d[i]];
			cnt[d[i]]++;
		}
		cout << ans << endl;
		/*ll ans = 0ll;
		for(auto &x: mp)
			ans += ((x.S-1)*x.S)/2ll;

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


Measured memory_bytes: 2708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,A[200001],mod=1e9+7;
    cin>>n;
    rep(i,n) cin>>A[i];
    ll ans=1,r=0,b=0,g=0;
    rep(i,n){
        ll a=0,c=0;
        if(r==A[i]){
            a++;
            if(c==0) r++,c++;
        }
        if(b==A[i]){
            a++;
            if(c==0) b++,c++;
        }
        if(g==A[i]){
            a++;
            if(c==0) g++,c++;
        }
        ans=ans*a%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int a,b,c;

int main(){
	cin>>a>>b>>c;
	for(int i=0;i<100;i++){
		if(a%2==1||b%2==1||c%2==1){
			cout<<i<<endl;
			return 0;
		}
		int A=(b+c)/2,B=(a+c)/2,C=(a+b)/2;
		a=A;
		b=B;
		c=C;
	}
	cout<<-1<<endl;
}

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

public class Main {

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		String s = fr.nextLine();
		int bCount = 0;
		long count = 0;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'B') {
				bCount++;
			} else {
				count += bCount;
			}
		}
		System.out.println(count);
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 29572
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntListN n = map readInt <$> replicateM (fromIntegral n) BS.getLine

main = do
  n <- getInt
  ss <- getIntListN n
  let ssum = sum ss
  if ssum `mod` 10 /= 0
    then print ssum
    else do
      let nzs = filter (\x -> x `mod` 10 /= 0) ss
      if length nzs == 0
        then print 0
        else print $ ssum - head (sort nzs)


Measured memory_bytes: 3772
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
int dp[21][50001];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin>>n>>m;
	vi c(m);
	rep(i,m)cin>>c[i];
	rep(i,m+1)rep(j,n+1)dp[i][j]=INF;
	dp[0][0]=0;
	rep(i,m){
		rep(j,n+1){
			if(j-c[i]>=0)
				dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1);
			else 
				dp[i+1][j]=dp[i][j];
		}
	}
	/*REP(i,1,m+1){
		rep(j,n+1)p(dp[i][j]);
		cout<<endl;
	}*/
	P(dp[m][n]);
	return 0;
}

Measured memory_bytes: 7300
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
map<int,int> mp, l;
ll a[100010];
int main(){
  int n;
  while(cin>>n){
    mp.clear();l.clear();
    for(int i=0; i<n; ++i){
      scanf("%lld",&a[i]);
      ++mp[a[i]];
      l[a[i]]=0;
    }
    sort(a, a+n);
    reverse(a, a+n);
    int d=0;
    ll ans=1;
    for(int i=0; i<n; ++i){
      if(l[a[i]])
        continue;
      l[a[i]]=1;
      if(d>=2)
        break;
      if(mp[a[i]]>=4){
        if(d==0){
        ans=a[i]*a[i];
        d=2;
        }
        else{
          ans*=a[i];
          ++d;
        }
      }
      else if(mp[a[i]]>=2){
        ans=ans*a[i];
        ++d;
      }
    }
    if(d<2)
      cout<<0<<endl;
    else
      cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;



int main(){
  int N,K; cin >> N >> K;
  int ans = 0;
  if(K >= 2){
    ans = N - K;
  }
  cout << ans << endl;
}
  


  


Measured memory_bytes: 256
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
)

var (
	empty = []byte(".")
	ln    = []byte("\n")
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	sc := NewScanner(os.Stdin)
	sc.SetSplitter("")

	var grid [1001][1001]bool
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			b := sc.Bytes()
			if bytes.Equal(b, ln) {
				b = sc.Bytes()
			}
			grid[i][j] = bytes.Equal(b, empty)
		}
	}

	var dp [1001][1001]int
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i+1][j] {
				dp[i+1][j] = (dp[i][j] + dp[i+1][j]) % Mod
			}
			if grid[i][j+1] {
				dp[i][j+1] = (dp[i][j] + dp[i][j+1]) % Mod
			}
		}
	}

	fmt.Println(dp[h-1][w-1])
}

// generated by https://github.com/murosan/gollect

const Mod = 1000000007

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) Bytes() []byte { s.Scan(); return s.Scanner.Bytes() }

func (s *Scanner) SetSplitter(sep string) {
	switch sep {
	case "":
		s.Split(bufio.ScanRunes)
	case " ":
		s.Split(bufio.ScanWords)
	default:
		s.Split(bufio.ScanLines)
	}
}


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

int main() {
  
  int64_t L,R;
  int ans=2018;
   int LL,RR;
    
  
  cin >> L >> R;
  
  
  if(R-L>=2019){
    ans =0;
  }
  
  
  else{
    
    LL = L%2019;
    RR = R%2019;
    
    
    if(LL<RR){
      
       for(int64_t i=LL;i<=RR-1;i++){
          for(int64_t j=i+1;j<=RR;j++){
            int a;
            a=((i%2019)*(j%2019))%2019;
                if(a<ans){
                    ans = a;
    		    }
   		  }
       }
    }
    else{
      ans =0;
    }
  }
  
  cout << ans << endl;
    
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll arr[100004];
// ll st[4 * 100004];
// void build(ll si, ll ss, ll en)
// {
//     if (ss == en)
//     {
//         st[si] = arr[ss];
//         return ;
//     }
//     ll mid = ss + (en - ss) / 2;
//     build(2 * si, ss, mid);
//     build(2 * si + 1, mid + 1, en);
//     st[si] = min(st[2 * si], st[2 * si + 1]);

// }
// ll query(ll si, ll ss, ll en, ll qs, ll qe)
// {
//     if (ss > qe || en < qs)
//         return INT_MAX;
//     if (ss >= qs and en <= qe)
//         return st[si];
//     ll mid = ss + (en - ss) / 2;
//     return min(query(2 * si, ss, mid, qs, qe), query(2 * si + 1, mid + 1, en, qs, qe));
// }
int main()
{

#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output12.txt", "w", stdout);
#endif
    ll n;
    cin >> n;
    string str;
    map<string, ll>ma;
    for (ll i = 1; i <= n; i++)
    {
        cin >> str;
        ma[str]++;
    }
    cout << "AC" << " " << "x" << " " << ma["AC"] << "\n";
    cout << "WA" << " " << "x" << " " << ma["WA"] << "\n";
    cout << "TLE" << " " << "x" << " " << ma["TLE"] << "\n";
    cout << "RE" << " " << "x" << " " << ma["RE"] << "\n";
    return 0;

}


Measured memory_bytes: 3632
N, M = map(int, input().split())
S = list(map(int, input().split()))
S.append(-1)
T = list(map(int, input().split()))
T.append(0)
mod = 10 ** 9 + 7
dp0 = [[0] * 2005 for _ in range(2005)]
dp1 = [[0] * 2005 for _ in range(2005)]
dp0[0][0] = 1
for i in range(N + 1):
    for j in range(M + 1):
        dp0[i + 1][j] += dp0[i][j] % mod
        dp1[i][j] += dp0[i][j] % mod
        dp1[i][j + 1] += dp1[i][j] % mod
        if S[i] == T[j]:
            dp0[i + 1][j + 1] += dp1[i][j] % mod
ans = dp1[N][M] % mod
print(ans)

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

using namespace std;

long long const mod = 1000000007ll;

int main(){
  int N;
  cin >> N;
  
  vector<int> d(60, 0);
  vector<long long> A(N);
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
    for(int j = 0; j < 60; j++){
      if(A[i] & (1ll << j)) d[j]++;
    }
  }
  
  long long sum = 0ll;
  for(int i = 0; i < N; i++){
    long long k = 1ll;
    for(int j = 0; j < 60; j++){
      if(A[i] & (1ll << j)){
        sum += (k % mod) * (long long)(N - i - d[j]) % mod;
        d[j]--;
      }else{
        sum += (k % mod) * (long long)d[j] % mod;
      }
      k *= 2;
      sum %= mod;
    }
  }
  
  cout << sum << endl;
  
  return 0;
}



Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
	int a,b,c,n;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
	n=a;	a=b;	b=n;
	}
	if(b>c){
	n=b;	b=c;	c=n;
	}
	if(a>b){
	n=a;	a=b;	b=n;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2072
#include "stdio.h"

int main(void) {

    int N,L[110],i=0,j=0,k=0,count=0;

    scanf("%d",&N);

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

    for (i = 0; i < N; i++) {
        for (j = i+1; j < N; j++) {
            for (k = j+1; k < N; k++) {
                if ((L[i] != L[j]) && (L[j] != L[k]) && (L[k] != L[i])) {
                    if ((L[i] + L[j] > L[k]) && (L[i] + L[k] > L[j]) && (L[k] + L[j] > L[i])) {
                        count++;
                    }
                }
            }
        }
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 1736
# -*- coding: utf-8 -*-
multi_0 = [a for a in range(1,100)]
multi_100 = [a for a in range(100,10000) if a % 100 == 0]
multi_10000 = [a for a in range(10000, 1000000) if a % 10000 == 0]

multi_0 += [101]
multi_100 += [10100]
multi_10000 += [1010000]

D, N = map(int, input().split())
if D == 0:
    print(multi_0[N-1])
elif D == 1:
    print(multi_100[N-1])
elif D == 2:
    print(multi_10000[N-1])


Measured memory_bytes: 3064
#a = int(input())
#b,c = map(int,input().split())
#s = input()
#list_s = list(input())
#list_int = list(map(int,input().split()))

#list = [0 for i in range(n)]
#dp = [[0 for i in range(A)] for j in range(B)]

#list_int 並べて出力 print (' '.join(map(str,ans_li)))
#list_str 並べて出力 print (' '.join(list))

# 2進数 format(10, 'b') # '1010'

# aa=[int(input()) for i in range(n)]

#for i,name in enumerate(list)

''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) #heapqの作成
heapq.heappush(queue,num) #numのpush(値の追加)
pop = heapq.heappop(queue) #numのpop(最小値の出力)
pop = heapq.heappushpop(queue,num) #push -> pop

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7

N,M = map(int,input().split())
ab_list = []
ans = [[INF,0]]*N

for i in range(N):
	a,b = map(int,input().split())
	ab_list.append([a,b])

for i in range(M):
	c,d = map(int,input().split())
	for n,[a,b] in enumerate(ab_list):
		dist = abs(a-c)+abs(b-d)
		if ans[n][0] > dist:
			ans[n] = [dist,i]

for i in range(N):
	print(ans[i][1]+1)


Measured memory_bytes: 3884
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
 
namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }
 
    class Solution
    {
        string N, M;
        string T = "0";
        public Solution()
        {
            N = Console.ReadLine();
 
            int j = N.Length;
            string[] M_split = new string[j];
 
            int i;
            for (i = 0; i < j; i++)
            {
                M_split[i] = N.Substring(i, 1);
            }
 
            var qry = from a in M_split
                      select a;
 
            List<string> lst = new List<string>();
            lst = qry.ToList();
            lst = lst.Distinct().ToList();
            lst.Sort();
 
            string[] D = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
 
 
            for (i = 0; i < 26; i++)
            {
                if (i < lst.Count())
                {
                    if (D[i] != lst[i])
                    {
                        T = D[i];
                        i = 27;
                    }
                }
                else
                {
                    T = D[i];
                    i = 27;
                }
            }
 
            if (T == "0")
            { T = "None"; }
        }
 
        public void answer()
        {
            Console.WriteLine(T);
        }
    }
}

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

const long long mod = 1e9 + 7;

int sum_1[60];
int main(){
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        long long a;
        cin >> a;
        for (int j = 0; j < 60; j++)
        {
            sum_1[j] += a&1;
            a >>= 1;
        }
    }
    long long pow_2 = 1;
    for (int i = 0; i < 60; i++)
    {
        sum += (pow_2 * sum_1[i] % mod) * (n - sum_1[i]) % mod;
        sum %= mod;
        pow_2 *= 2;
        pow_2 %= mod;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}
void solve()
{
	int a, b, c, d;
	cin >> a;
	cout << 1 - a << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
S = input()
T = input()

candidates = []
for i in range(len(S) - len(T) + 1):
    is_ok = True
    for j in range(len(T)):
        if S[i+j] == '?' or S[i+j] == T[j]:
            pass
        else:
            is_ok = False

    # print(is_ok)
    if is_ok:
        candidate = S[:i] + T + S[i+len(T):]
        candidate = candidate.replace('?', 'a')
        candidates.append(candidate)

if candidates:
    candidates.sort()
    print(candidates[0])
else:
    print('UNRESTORABLE')

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace tree {
struct union_find {
  vector<int> par, rank, size;
  int compnum;

  union_find(int N) {
    compnum = N;
    par.resize(N), rank.resize(N), size.resize(N);
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int main() {

  int N, K, L; cin >> N >> K >> L;
  tree::union_find uf1(N), uf2(N);
  rep(i, K) {
    int a, b; cin >> a >> b; a--, b--;
    uf1(a, b);
  }

  rep(i, L) {
    int a, b; cin >> a >> b; a--, b--;
    uf2(a, b);
  }

  map<pair<int, int>, int> mp;
  rep(i, N) {
    mp[{uf1[i], uf2[i]}]++;
  }

  rep(i, N) {
    cout << mp[{uf1[i], uf2[i]}] << endl;
  }
  
  return 0;
}

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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N * 3);
  for (int i = 0; i < N * 3; i++) {
    cin >> A[i];
  }
  vector<vector<long long>> score(N + 1, vector<long long>(2));

  multiset<int> s;
  long long ssum = 0;
  for (int i = 0; i < N; i++) {
    s.insert(A[i]);
    ssum += A[i];
  }
  score[0][0] = ssum;
  for (int i = N; i < N * 2; i++) {
    s.insert(A[i]);
    ssum += A[i];
    auto first = s.begin();
    ssum -= *first;
    s.erase(first);
    score[i - N + 1][0] = ssum;
  }

  s.clear();
  ssum = 0;
  for (int i = N * 2; i < N * 3; i++) {
    s.insert(A[i]);
    ssum += A[i];
  }
  score[N][1] = ssum;
  for (int i = N * 2 - 1; i >= N; i--) {
    s.insert(A[i]);
    ssum += A[i];
    auto last = s.end();
    last--;
    ssum -= *last;
    s.erase(last);
    score[i - N][1] = ssum;
  }

  long long ans = -1e18 - 10;
  for (int i = 0; i < N + 1; i++) {
    chmax(ans, score[i][0] - score[i][1]);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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


int main()
{
    string str;
    int num,i,sum=0;
    cin>>str;
    int len = str.size();

    stringstream s;
    s<<str;
    s>>num;

    for(i=0;i<len;i++)
    {
        sum = sum + (str[i]-'0');
    }

    if(num%sum==0)
    cout<<"Yes"<<endl;

    else
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool use[12];
bool ok(int n)
{
	while(n>0)
	{
		if(use[n%10])
		return false;
		n/=10;
	}
	return true;
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		int d;
		scanf("%d",&d);
		use[d]=true;
	}
	while(!ok(n))
	n++;
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i)

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

  int N;
  vector<ll> A(9);
  vector<ll> B(N);

  for (ll i = 0; i < 9; i++) {
    cin >> A.at(i);
  }

  cin >> N;

  for (ll i = 0; i < N; i++) {
    cin >>B.at(i);
  }

  vector<ll> C(9);
  for (ll i = 0; i < 9; i++) {
    C.at(i)=0;
  }

  for (ll i = 0; i < 9; i++) {
    for (ll j = 0; j < N; j++) {
      if(A.at(i)==B.at(j)){
        C.at(i) = 1;
      }
    }
  }

  if(C.at(0)+C.at(1)+C.at(2)==3){
    cout << "Yes" << endl;
  }
  else if (C.at(3) + C.at(4) + C.at(5) == 3)
  {
    cout << "Yes" << endl;
  }
  else if (C.at(6) + C.at(7) + C.at(8) == 3)
  {
    cout << "Yes" << endl;
  }
  else if (C.at(0) + C.at(3) + C.at(6) == 3)
  {
    cout << "Yes" << endl;
  }
  else if (C.at(1) + C.at(4) + C.at(7) == 3)
  {
    cout << "Yes" << endl;
  }
  else if (C.at(2) + C.at(5) + C.at(8) == 3)
  {
    cout << "Yes" << endl;
  }
  else if (C.at(0) + C.at(4) + C.at(8) == 3)
  {
    cout << "Yes" << endl;
  }
  else if (C.at(2) + C.at(4) + C.at(6) == 3)
  {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
/*
dp[i][0]:上からi桁目まで見て、ぴったり支払う時の使用紙幣の枚数の最小値
dp[i][1]:上からi桁目まで見て、i桁目は余分に払っておつりをもらう
*/
ll dp[1000100][2];
int main()
{
    cout << fixed << setprecision(30);
    string S;
    cin >> S;
    ll N = S.size();
    loop(i, N + 10)
    {
        dp[i][0] = 1e18;
        dp[i][1] = 1e18;
    }
    dp[0][0] = 0;
    dp[0][1] = 1;
    loop(i, N)
    {
        ll now = ctoi(S[i]);
        //0->0
        chmin(dp[i + 1][0], dp[i][0] + now);
        //1->0
        chmin(dp[i + 1][0], dp[i][1] + (10 - now));
        //0->1
        chmin(dp[i + 1][1], dp[i][0] + now + 1);
        //1->1
        chmin(dp[i + 1][1], dp[i][1] + (9 - now));
    }
    putout(dp[N][0]);
    return 0;
}


Measured memory_bytes: 20080
#include <bits/stdc++.h>
using namespace std;
int main () {
 int H;
  cin>>H;
  int N;
  cin>>N; 
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
  cin >> a.at(i);
}
 int d;
  d=std::accumulate(a.begin(), a.end(), 0);
  if(d<H){
    cout<<"No"<<endl;
  }
  else {
    cout<<"Yes"<<endl;
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

int n, ans = 1e9;

int get(int x) {
	int res = 0;
	do {
		res += x % 10;
		x /= 10;
	}	while (x);
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i < n; i++) {
		int j = n - i;
		ans = min(ans, get(i) + get(j));
	}
	cout << ans;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
        a.append(a[i]+A[i])
for i in range(M):
        b.append(b[i]+B[i])

ans, j = 0, M

for i in range(N+1):
        if a[i] > K:
                break
        while b[j] > K - a[i]:
                j -= 1
        ans = max(ans, i+j)

print(ans)


Measured memory_bytes: 47552
#include <cstdio>

int main()
{
  int n,k;
  static char P[10000][20];
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%s",P[i]);
  }
  int C[26]={0};
  for(int i=0;i<n;i++){
    C[P[i][0]-'A']++;
  }
  int L=0,R=n+1;
  while(L+1<R){
    int m=(L+R)/2;
    int g=0;
    for(int i=0;i<26;i++){
      if(C[i]<m){
	g+=C[i];
      }
      else{
	g+=m;
      }
    }
    if(g>=m*k){
      L=m;
    }
    else{
      R=m;
    }
  }
  printf("%d\n",L);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>a(m), b(m), c(n);
	rep(i, m) {
		cin >> a[i] >> b[i];
		if (a[i] == 1)c[b[i]]++;
		if (b[i] == n)c[a[i]]++;
	}
	bool flag = false;
	rep(i, n) {
		if (c[i] == 2)flag = true;
	}
	if (flag)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

string replace(int a,int b,string s,string p){
  for(int i=0;i<(b-a+1);i++){
    s[a+i]=p[i];
  }
  return s;
}

string reverse(int a,int b,string s){
  char tmp;
  for(int i=0;i<(b-a+1)/2;i++){
    tmp=s[a+i];
    s[a+i]=s[b-i];
    s[b-i]=tmp;
  }
  return s;
}

void myprint(int a,int b,string s){
  for(int i=a;i<(b+1);i++){
    cout << s[i];
  }
  cout << endl;
}

int main(void){
  int n, a, b;
  string s,inst,p;
  cin >> s >> n;
  for(int i=0;i<n;i++){
    cin >> inst;
    if(inst=="replace"){
      cin >> a >> b >> p;
      s=replace(a,b,s,p);
    }else if(inst=="reverse"){
      cin >> a >> b;
      s=reverse(a,b,s);
    }else{
      cin >> a >> b;
      myprint(a,b,s);
    }
  }
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    transform(s.begin(), s.end(), s.begin(), [](char c) { return c - '0'; });

    int64_t n = s.size();
    vector<vector<int64_t>> dp(3, vector<int64_t>(n + 1));
    dp[0][0] = 0;
    dp[1][0] = 2;
    dp[2][0] = 1;
    for (auto i : irange(0L, n)) {
        dp[0][i + 1] = dp[0][i] + s[i];
        dp[1][i + 1] = min(
                {dp[0][i] + s[i] + 2, dp[1][i] + s[i], dp[2][i] + (10 - s[i])});
        dp[2][i + 1] = min({dp[0][i] + s[i] + 1, dp[1][i] + s[i] + 1,
                            dp[2][i] + (10 - s[i] - 1)});
    }

    cout << min(dp[0][n], dp[1][n]) << endl;
}

Measured memory_bytes: 32644
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    array<int, 256> v{};
    string s;
    while(cin >> s) {
        if(s[s.size()-2] != ',') v[2]++;
        else if(s.back() == 'A') v[0]++;
        else if(s.back() == 'B') v[1]++;
        else if(s.back() == 'O') v[3]++;
    }
    printf("%d\n%d\n%d\n%d\n", v[0], v[1], v[2], v[3]);
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair

int main() {
int r;
cin>>r;
cout<<fixed<<setprecision(3)<<2*r*3.141<<endl;
return 0;
}


Measured memory_bytes: 3784
n, d = gets.split.map &:to_i
a = n.times.map{gets.split.map &:to_i}
ans = 0
(0...n).each do |i|
  (i+1...n).each do |j|
    l = (0...d).inject(0){|s, k| s+(a[i][k]-a[j][k])**2}
    ll = Math.sqrt(l).floor
    ans += 1 if ll*ll==l
  end
end
p ans

Measured memory_bytes: 3836
N = int(input())
A = list(map(int, input().split()))
q = 10 ** 9 + 7
ans = 0
cnt = [0] * 61
for i in range(N):
    b = bin(A[i])[2:].zfill(61)
    for i in range(61):
        if b[i] == '1':
            cnt[i] += 1
for num, c in enumerate(cnt[::-1]):
    zero = N - c
    ichi = c
    ans += zero * ichi * (2 ** num)
    ans = ans % q
print(ans % q)


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

int main(){
    string s, t; cin >> s >> t;
    bool flag = false;
    for(int i=0;i<s.size();i++){
        string u = s.substr(i, s.size()-i) + s.substr(0, i);
        if(u == t){
            flag = true;
            break;
        }
        else{
            flag = false;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

/*substrの注意
substr(i, n)において、iは.at(i)ではない*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int A, B, C, i, x, r;
  bool can = false;
  cin >> A >> B >> C;
  for (i = 1; i <= B; i++){
    x = A * i;
    r = x % B;
    if (r == C){
      can = true;
      break;
    }
  }
  if (can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    int n = s.back()-'0';

    if (n==3) {
        cout << "bon" << '\n';
    }
    else if (n == 0 || n==1 || n==6 || n==8) {
        cout << "pon" << '\n';
    }
    else {
        cout << "hon" << '\n';
    }

    return 0;
}

Measured memory_bytes: 3552
a = list(map(int,input().split()))
x = a[0]
n = a[1]
if n>0:
  b = list(map(int,input().split()))
  c = list(range(-n,101+n))

  
  for i in range(n):
    if b[i] in c:
      c.remove(b[i])

  
  k = 1000
  kn = 0

  for i in range(len(c)):
    if k>abs(x-c[i]):
      k = x-c[i]
      kn = c[i]
  print(kn)
else:
  print(x)
  

Measured memory_bytes: 9208
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll powmod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) { //逆元
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

//宣言とか

/*signed*/int main(void) {
    ld sw = 2.0 * pi;
    sw = sw / 60.0;
    ld lw = sw / 12.0;
    sw = sw - lw;
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    m = 60.0 * h + m;
    ld ang = m * sw;
    a = a * a + b * b - 2.0 * a * b * cos(ang);
    a = sqrt(a);
    cout << fixed << setprecision(15) << a << endl;
    return 0;
}

Measured memory_bytes: 4164