akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S
import qualified Data.Array.IArray as A
import Data.Maybe
import Data.Bool

main = do
  [n,_] <- map read . words <$> getLine
  es <- readUndirectedEdge <$> B.getContents
  let g = buildG n es
  putStrLn $ bool "IMPOSSIBLE" "POSSIBLE" (voyage n g)

voyage n g = S.foldr (\x acc -> S.member n (from g x) || acc) False (from g 1)

type Vertex = Int
type Vertexes = S.IntSet
type Edge = (Vertex, Vertex)
type Graph = A.Array Vertex Vertexes

buildG :: Int -> [Edge] -> Graph
buildG n = A.accumArray (flip S.insert) S.empty (1, n)

from :: Graph -> Vertex -> Vertexes
from g = (g A.!)

readUndirectedEdge :: B.ByteString -> [Edge]
readUndirectedEdge = concatMap (constructTwoWay . map readInt . B.words) . B.lines

constructTwoWay :: [Int] -> [Edge]
constructTwoWay [s,t] = [(s, t), (t, s)]
constructTwoWay _ = undefined

readInt :: B.ByteString -> Int
readInt = fst . fromJust . B.readInt


Measured memory_bytes: 57212
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
   int n;
   while(scanf("%d",&n)!=EOF)
   {  long long sum=0;
       for(int i=1;i<=n;i++)
       {
           sum=sum+i;
       }
   printf("%lld\n",sum);
   }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool dfs(string s, string &t, int p = 0){
	if(p >= s.size()) return s == t;
	if(s[p]=='A'){
		string a = s.substr(0,p) + s.substr(p+1);
		if(dfs(a, t, p)) return true;
	}
	return dfs(s, t, p+1);
}

void mainmain(){
	string s = "AKIHABARA";
	string t;
	cin>>t;
	cout<<(dfs(s,t)?"YES":"NO")<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
def main():
    n,m = map(int,input().split())
    ab = [list(map(int,input().split())) for _ in range(m)]
    g = [[] for _ in range(n)]
    for a,b in ab:
        g[a-1].append(b-1)
        g[b-1].append(a-1)
    
    dist = [-1]*n
    from collections import deque
    dist[0] = 0
    q = deque()
    q.append(0)
    while q:
        v = q.popleft()
        for nv in g[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = v
            q.append(nv)
    
    print('Yes')
    for v in range(1,n):
        print(dist[v]+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 122712
#include<iostream>

using namespace std;

int main()
{
	int amount;
	cin >> amount;
	int mod = amount % 100;
	int maxCnt = amount / 100;
	if ((mod / 5) + ((mod % 5 == 0) ? 0 : 1) > maxCnt) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}


    return 0;
}


Measured memory_bytes: 256
def floor(x,A,B):
    return int(A*x/B)-(A*int(x/B))

def main():
    A,B,N=map(int,input().split())

    if N<=B-1:
        res_x=N
    else:
        res_x=B-1

    res=floor(res_x,A,B)
    print(res)

if __name__=="__main__":
    main()


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

public class Main {

    //https://atcoder.jp/contests/dp/tasks/dp_a

   private static int[] dp = null;

    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dp = new int[n + 1];
        Arrays.fill(dp, -1);

       /* int value = dfs(arr, n, 0);
        System.out.println(value);*/

        int val = solveTopDown(n - 1, arr);
        System.out.println(val);

    }

    private static int dfs( int[] arr, int n, int temp ) {

       /* if (dp[temp] != -1)
            return dp[temp];*/

        if (temp == n) //if no element in an array then
            return 0;

        if (temp == n - 1) //if no element in an array then
            return arr[n - 1];

        if (temp == n - 2) //if only element in array then difference of two will be the cost.
            return Math.abs(arr[temp] - arr[temp - 1]);

        for (int i = temp; i < n; i++) {

            if (i + 2 < n) {

                dp[i] = Math.min(Math.abs(arr[i] - arr[i + 1]) + dfs(arr, n, i + 1)
                        , Math.abs(arr[i] - arr[i + 2]) + dfs(arr, n, i + 2));
            }
        }

        return dp[n];
    }

    private static int solveTopDown( int i, int[] arr ) {
        if (dp[i] != -1) {
            return dp[i];
        }

        if (i == 0) { //if one element left
            dp[i] = 0;
            return dp[i];
        } else if (i == 1) { //if two left
            dp[i] = Math.abs(arr[i] - arr[i - 1]);
            return dp[i];
        }

        dp[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + solveTopDown(i - 1, arr)
                , Math.abs(arr[i] - arr[i - 2]) + solveTopDown(i - 2, arr));

        return dp[i];
    }
}

Measured memory_bytes: 63492
N, *I = map(int, open(0).read().split())
AB = set(zip(*[iter(I[:2 * N])] * 2))
CD = sorted(zip(*[iter(I[2 * N:])] * 2))

for c, d in CD:
    ma = max(((a, b) for a, b in AB if a < c and b < d), key=lambda x: x[1], default=None)
    if ma:
        AB.remove(ma)

print(N - len(AB))

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

int main () {
	int n;
	string s;
	regex r("Hoshino");
	cin >> n;
	getline(cin, s);
	while (n--) {
		getline(cin, s);
		cout << regex_replace(s, r, "Hoshina") << endl;
	}
}


Measured memory_bytes: 3108
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var str = input;



  var count = 0;

  for ( var i = 0; i < str.length; i++ ){
    if ( str[i] == 'x' ) {
      count++;
    }
  }

  if ( count >= 8 ){
    console.log('NO\n');
  } else {
    console.log('YES\n');
  }

  

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21572
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
int edge[8][8];

int DFS(int index, int N, int value)
{
	//cout << index << endl;
	int sum = 0;

	if (value == 0)
	{
		return 1;
	}

	for (int i = 0; i < N; i++)
	{
		if ((edge[index][i] == 1) &&  ((value & (1 << i)) != 0))
		{
			sum += DFS(i, N, value & (~(1 << i)));
		}
	}
	return sum;
}

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

	int N, M;
	
	cin >> N >> M;

	#if 0
	//vector< pair<int, int> > edgy;
	map<int, std::vector<int> > edge;
	rep(i, M)
	{
		int a, b;
		cin >> a >> b;
		if (edge.find(a) == edge.end())
		{
			std::vector<int> v;
			v.pb(b);
			edge[a] = v;
		}
		else
		{
			edge[a].pb(b);
		}

		if (edge.find(b) == edge.end())
		{
			std::vector<int> v;
			v.pb(a);
			edge[b] = v;
		}
		else
		{
			edge[b].pb(a);
		}
	}
	#endif

	memset(edge, 0, sizeof(edge));

	rep(i, M)
	{
		int a, b;
		cin >> a >> b;
		edge[a-1][b-1] = 1;
		edge[b-1][a-1] = 1;
	}

	cout << DFS(0, N, (1 << N) - 1 - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
typedef long long ll;

using namespace std;
char a[1000];
int main()
{
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i <len; i++)
    {
        if(a[i] == 'A' && a[i+1] == 'C')
        {
            cout << "Yes" << endl;
            break;
        }
        if(i == len-1)cout << "No" << endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200002],n,k,ans;
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;++i)ans+=a[i];
	printf("%lld",ans);
}


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

int main() {
  int N , K , x , y , l=1;
  cin >> N >> K;
  for (int i = 0;i < N; i++) {
    x = l*2 , y = l+K;
    if (x < y) {
      l *=2;
    }
    
    else l+=K;
  }
  cout << l << endl;
}

Measured memory_bytes: 256
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        num = 0
        for k in range(d):
            num += (x[i][k] - x[j][k])**2
        for l in range(200):
            if num == l**2:
                ans += 1
print(ans)

Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    if(a[0] !=0 ) {cout<<-1<<endl; return 0;}
    rep(i,n-1){
        if(a[i+1] - a[i]>=2) {cout<<-1<<endl; return 0;}
    }
    int cnt = 0,ans = 0;
    for(int i=0;i<n;i++){
       if(a[i] == 0) {ans += cnt; cnt = 0; continue;}
       if(a[i]==a[i-1] + 1) cnt++;
       if(a[i]<a[i-1]) cnt += a[i];
       if(a[i] == a[i-1]) cnt += a[i];
      
    }
    cout<<ans + cnt<<endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#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(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int h;

  cin >> h;

  int a = floor(log2(h));

  cout << pow(2, a + 1) - 1 << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
}
int main() {
  vector<vector<int>> A(3,vector<int>(3));
  vector<vector<bool>> S(3,vector<bool>(3,false));
  rep(i,3){
    rep(j,3){
      cin>>A[i][j];
    }
  }
  int N; cin>>N;
  rep(q,N){
    int B; cin>>B;
    rep(i,3){
      rep(j,3){
        if(B==A[i][j]) S[i][j]=true;
      }
    }
  }
  bool bingo=false;
  if(S[0][0]&&S[1][1]&&S[2][2]) bingo=true;
  if(S[0][2]&&S[1][1]&&S[2][0]) bingo=true;
  rep(i,3) if(S[i][0]&&S[i][1]&&S[i][2]) bingo=true;
  rep(i,3) if(S[0][i]&&S[1][i]&&S[2][i]) bingo=true;
  YN(bingo);
}


Measured memory_bytes: 3568
def solve(n, a, b):
    if (a-b) % 2 == 0:
        return (abs(a-b)+1) // 2
    else:
        s = min(n-a, n-b) + 1
        x = s + solve(n, min(a+s, n), min(b+s, n))
        t = min(a, b)
        y = t + solve(n, max(a-t, 1), max(b-t, 1))
        return min(x, y)

n, a, b = map(int, input().split())
print(solve(n, a, b))

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ParseException {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		double total = 0;
		for(int i=0; i < N; i++) {
			double d = sc.nextDouble();

			if("JPY".equals(sc.next())) {
				total += d;
			}else {
				total += d * 380000.0;
			}
		}
		System.out.println(total);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,x,n,flag;
    scanf("%d %d",&x,&n);
    int num[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
    }
    for(i=0;;i++)
    {
        flag=1;
        for(j=0;j<n;j++)
        {
            if((x-i)!=num[j])flag*=1;
            if((x-i)==num[j])flag*=0;
        }
        if(flag==1)
        {
            printf("%d",x-i);
            return 0;
        }
        flag=1;
        for(j=0;j<n;j++)
        {
            if((x+i)!=num[j])flag*=1;
            if((x+i)==num[j])flag*=0;
        }
        if(flag==1)
        {
            printf("%d",x+i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int concate[200][200];
vector<int> G[200];

int main()
{
	memset(concate, -1, sizeof(concate));
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	rep (i, 200) G[i].clear();
	int N; cin >> N;

	rep (i, N){
		for (int j = i + 1; j < N; ++j){
			if (concate[i][j] == 1 || concate[j][i] == 1) continue;
			string s(N, '0');
			s[i] = '1'; s[j] = '1';
			cout << "? " << s << endl;
			int d; cin >> d;
			if (d == 1){
				G[i].push_back(j);
				concate[i][j] = 1;
				concate[j][i] = 1;
			} // end if
		} // end for
	} // end rep
	
	vector<P> ans; ans.clear();
	rep (i, 200){
		if (G[i].empty()) continue;
		rep (j, (int)G[i].size()){
			ans.push_back(P(i, G[i][j]));
		} // end rep
	} // end rep

	cout << "! ";
	int m = (int)ans.size();
	rep (i,m){
		cout << '(' << ans[i].first << ',' << ans[i].second << ')' << (i != m - 1 ? ' ' : '\n');
	} // end rep
		
	return 0;
}

Measured memory_bytes: 1100
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>



using namespace std;


int main() {
	int n, m, c, cnt = 0;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b.at(i);
	}
	int sumer = 0;
	int a;
	for (int i = 0; i < n; i++) {
		a = 0;
		sumer = 0;
		for (int j = 0; j < m; j++) {
			cin >> a;
			sumer += (a * b.at(j));
		}
		sumer += c;
//		cout << sumer << endl;
		if (sumer > 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int n;
    cin>>n;
    ll sum = 0;
    FOR(i, 1, n+1) {
        if(i%3!=0 && i%5!=0) sum += i;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    class union_find{
            vector<long> parent, tree_size;
        public:
            union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
                for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
            }
            ll find(ll x){
                while(parent[x] != x)x = parent[x] = parent[parent[x]];
                return x;
            }
            void merge(ll a, ll b){
                a = find(a);
                b = find(b);
    	    if(a==b) return;
                if(tree_size[a] < tree_size[b])swap(a, b);
                tree_size[a] += tree_size[b];
                parent[b] = a;
                return;
            }
    	bool same(ll a, ll b){
    	    a = find(a);
    	    b = find(b);
    	    return a == b;
    	}
        };
    //uf.mergeのように使う
    //ufはMAX_N+1でとるか、代入時に0-indexedにする
    cin>>N>>M;
    union_find uf(N + 10);
    rep(i, M){
        int a, b;
        cin>>a>>b;
        uf.merge(a, b);
    }
    set<ll> s;
    rep(i, N) {
        //cout<<uf.find(i + 1)<<endl;
        s.insert(uf.find(i + 1));
    }
    cout<<s.size() - 1<<endl;
}


Measured memory_bytes: 8308
from itertools import product


def solve(string):
    h, w, *s = string.split()
    h, w = map(int, [h, w])
    s = ["#" + _s + "#" for _s in s]
    s = ["#" * (w + 2)] + s + ["#" * (w + 2)]
    ans = 0
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for _h, _w in product(range(1, h + 1), range(1, w + 1)):
        if s[_h][_w] == "#":
            continue
        c = [[h * w] * (w + 2) for _ in range(h + 2)]
        c[_h][_w] = 0
        q = list()
        for x, y in d:
            if s[_h + x][_w + y] == ".":
                q.append((_h + x, _w + y, _h, _w))
        if len(q) > 2:
            continue
        while q:
            cx, cy, px, py = q.pop()
            if c[px][py] + 1 >= c[cx][cy]:
                continue
            c[cx][cy] = c[px][py] + 1
            for x, y in d:
                nx = cx + x
                ny = cy + y
                if s[nx][ny] == ".":
                    q.append((nx, ny, cx, cy))
        for i, j in product(range(1, h + 1), range(1, w + 1)):
            ans = max(ans, c[i][j] * (s[i][j] == "."))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  // vector<int> X(5);
  // int x1, x2, x3, x4, x5;
  int a;
  cin >> a;
  cout << (a + a * a + a * a * a) << endl;

  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(){
  int T[5];
  for(int i = 0; i < 5; ++i) cin >> T[i];
  int N = 5, r = 0, ans = 0;
  for(int i = 0; i < N; ++i){
    ans += (T[i]+9)/10*10;
    r = max(r,((10-T[i]%10)%10+10)%10);
  }
  ans -= r;
  cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut map: HashMap<usize, usize> = HashMap::new();
    for i in 0..n {
        let _ = map.entry(i).or_insert(0);
    }

    for _ in 0..k {
        input! {
            d: usize,
            v: [usize; d],
        }
        for a in v.iter() {
            let entry = map.entry(a - 1).or_insert(0);
            *entry += 1;
        }
    }

    let mut ret = 0;
    for (_, &v) in map.iter() {
        if v == 0 {
            ret += 1;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2172
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int a,p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int mod = 1'000'000'007;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int ans = 0;
    int x = 0;
    rep(i,n){
        ans = (ans + (long long)a[i] * x) % mod;
        x = (x + a[i]) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
N,Q = map(int,input().split())
S = input()
LR = [list(map(int,input().split())) for _ in range(Q)]
#print(LR)

C = [0 for _ in range(N+1)]
for i in range(1,N):
  if S[i-1] == 'A' and S[i] == 'C':
    C[i+1] = C[i] + 1
  else:
    C[i+1] = C[i]
#print(C)
for l,r in LR:
  print(C[r]-C[l])

Measured memory_bytes: 30716
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let mut a: Vec<u32> = (0..n).map(|_| read()).collect();

    a.sort();
    a.reverse();

    let mut alice = 0;
    let mut bob = 0;
    for i in 0..n {
        if i % 2 == 1 {
            bob += a[i as usize];
        } else {
            alice += a[i as usize];
        }
    }

    println!("{}", alice-bob);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

int x[maxn];
map<int, int> fuck;
map<int, int> fuck2;
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%d", x + i);
    int maxa = 0;
    int a=0;
    for (int i = 0; i < n; i += 2) {
        fuck[x[i]]++;
        if (fuck[x[i]] > maxa) {
            maxa = fuck[x[i]];
            a = x[i];
        }
    }
    int maxb = 0;
    int b=0;
    for (int i = 1; i < n; i += 2) {
        fuck2[x[i]]++;
        if (fuck2[x[i]] > maxb) {
            maxb = fuck2[x[i]];
            b = x[i];
        }
    }
    vector<int> A;
    vector<int> B;
    map<int, int>::iterator it;
    if (a == b) {
        A.push_back(0);
        B.push_back(0);
        for (it = fuck.begin(); it != fuck.end(); it++) {
            A.push_back((*it).second);
        }
        for (it = fuck2.begin(); it != fuck2.end(); it++) {
            B.push_back((*it).second);
        }
        sort(A.rbegin(), A.rend());
        sort(B.rbegin(), B.rend());
        if (A[0] - A[1] > B[0] - B[1]) {
            maxb = B[1];
        } else
            maxa = A[1];
    }
    cout << n - maxa - maxb;
}

Measured memory_bytes: 5888
function main(input){
  input = input.split(' ').map(parseFloat);
  
  if(input[0] >= 10 || input[1] >= 10){
    console.log(-1);
    return;
  }
  
  console.log(input.reduce((arr,cur) => arr * cur)); 
}
 
main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
if __name__ == "__main__":
    n = int(input().strip())
 
    chars = "abcdefghijklmnopqrstuvwxyz"
    ans = []
 
    while True:
        if n < 27:
            ans.append(chars[n - 1])
            break
 
        else:
            remainder = int(n % 26)
            n = int(n / 26)
            if remainder > 0:
                ans.append(chars[remainder - 1])
            else:
                ans.append(chars[-1])
                n -= 1
 
        
    print("".join(ans[::-1]))

Measured memory_bytes: 8868
#include <cstdio>
int main()
{
	char c1,c2,c3;
	scanf("%c %c %c", &c1,&c2,&c3);
	c1=='1' ? c1='9' : c1='1';
	c2=='1' ? c2='9' : c2='1';
	c3=='1' ? c3='9' : c3='1';
	printf("%c%c%c\n", c1,c2,c3);
	return 0;
}


Measured memory_bytes: 128
// A.

#pragma GCC target("avx2")
#pragma GCC optimize("O2")

#include <stdio.h>

typedef long long LL;

int main(int argc, char* argv[]) {
	char buffer[3072000];
	LL cnt[20][20] = {};
	LL sum[20][20] = {};
	LL n = 0, ans = 0;
	char c, *bufptr = buffer;
	fread(buffer, 1, 3072000, stdin);
	while ((c = *bufptr++) >= '0') {
		n = (n * 10) + (c - '0');
	}
	for (LL i = 0; i < n; ++i) {
		LL x = 0, two = 0, five = 9, df = 0;
		while ((c = *bufptr++) >= ' ') {
			if (c == '.') {
				df = -1;
			} else {
				x = (x * 10) + c - '0';
				five += df;
			}
		}
		two = __builtin_ctzll(x);
		x >>= two;
		two += five;
		while (x % 5 == 0) {
			++five;
			x /= 5;
		}
		cnt[two > 18 ? 18 : two][five] += 1;
	}
	for (int i = 0; i <= 18; ++i) {
		sum[i][0] = cnt[18 - i][18];
		for (int j = 1; j <= 18; ++j) {
			sum[i][j] += sum[i][j - 1] + cnt[18 - i][18 - j];
		}
	}
	for (int i = 1; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			ans += sum[i][j] * cnt[i][j];
			if (i >= 9 && j >= 9) {
				ans -= cnt[i][j];
			}
		}
	}
	printf("%lld\n", ans >> 1);
	return 0;
}


Measured memory_bytes: 4260
function Main( input ){
    input = input.split("\n");

    var n = parseInt(input[0],10);
    var a = input[1].split(" ");

    for(var i = 0;i < n;i++){
        a[i] = parseInt(a[i],10);
    }


    var ans = 0;

    var b = 0;
    for(var i = 1;i < n;i++){
        if(b == 0){
            b = a[i] - a[i - 1];
        }else if(b > 0){
            if(a[i] - a[i - 1] < 0){
                ans++;b = 0;
            }
        }else
        {
            if(a[i] - a[i - 1] > 0){
                ans++;b = 0;
             }
        }
    }

    ans++;
    console.log(ans);
}


Main( require( 'fs' ).readFileSync( '/dev/stdin', 'utf8' ) )



Measured memory_bytes: 17484
function Main(input) {
  input = input.split(" ");

  var N = ~~input[0];
  var Y = ~~input[1];

  var You = function(N, Y){
    this.howMany = N;
    this.howMuch = Y;
  }

  You.prototype = {
    check: function(){
      for(var howMany10000yen = 0; howMany10000yen <= this.howMany; howMany10000yen++){
        for(var howMany5000yen = 0; howMany5000yen <= this.howMany - howMany10000yen; howMany5000yen++){
          var howMany1000yen = this.howMany - howMany10000yen - howMany5000yen;
          var candidatePrice = howMany1000yen*1000 + howMany5000yen*5000 + howMany10000yen*10000;
          if(candidatePrice == this.howMuch) return String(howMany10000yen)+" "+String(howMany5000yen)+" "+String(howMany1000yen);
        }
      }
      return "-1 -1 -1";
    }
  }

  var you = new You(N, Y);
  console.log(you.check());
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int k;
	cin>>k;
	while(k--) cout<<"ACL";
	re 0;
}

Measured memory_bytes: 3604
str = gets.chomp
c0 = ['ii', 'ww', '()', ')(']
c1 = 'iw()'
c2 = ' iw'
l = str.size
res = (l/2).times.map{ |i|
  s = str[i] + str[l-1-i]
  if c0.include?(s) then 0
  elsif c1.include?(s[0]) || c1.include?(s[0]) then 1
  else 2
  end
}.reduce(:+)
res += c2.include?(str[l/2]) ? 0 : 1 if l % 2 == 1
p res

Measured memory_bytes: 8656
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    string S;
    cin >> S;
    int64_t s = S.size();
    map<char, int64_t>d;
    d['a'] = 0;
    d['b'] = 0;
    d['c'] = 0;
    for (int64_t i=0; i<s; i++) {
        d[S[i]] = d[S[i]] + 1;
    }

    int64_t kizyun = s / 3;
    bool ikeru = true;
    for (auto c : d) {
        if (kizyun > c.second) {
            ikeru = false;
            break;
        }
    }

    int64_t min_ = min({d['a'], d['b'], d['c']});
    int64_t max_ = max({d['a'], d['b'], d['c']});
    if (max_ - 1 > min_) {
        ikeru = false;
    }

    if (ikeru) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

class cakeTotal
{
public:
	cakeTotal(long long taste, int i, int j, int k) {
		this->taste = taste;
		this->i = i;
		this->j = j;
		this->k = k;
	};
	long long taste;
	int i;
	int j;
	int k;
};

class ijk
{
public:
	ijk(int i, int j, int k) {
		this->i = i;
		this->j = j;
		this->k = k;
	};
	int i;
	int j;
	int k;
};

bool operator< (const cakeTotal &cakeTotal1, const cakeTotal &cakeTotal2) {
	return cakeTotal1.taste < cakeTotal2.taste;
};

// 指定のijkが存在するか
bool search_processed_ijk(vector<ijk> processed_ijk, int i, int j, int k) {
	for (ijk tmp : processed_ijk) {
		if (tmp.i == i && tmp.j == j && tmp.k == k) {
			return true;
		}
	}
	return false;
}

int main(void)
{
	long long X, Y, Z, K;
	long long A[1009], B[1009], C[1009];
	vector<long long> vec;

	priority_queue<cakeTotal> pqLL;
	vector<ijk> processed_ijk;

	cin >> X >> Y >> Z >> K;
	FOR(i, 0, X) {
		cin >> A[i];
	}
	sort(A, A + X, greater<long long>());
	FOR(i, 0, Y) {
		cin >> B[i];
	}
	sort(B, B + Y, greater<long long>());
	FOR(i, 0, Z) {
		cin >> C[i];
	}
	sort(C, C + Z, greater<long long>());

	pqLL.push(cakeTotal(A[0] + B[0] + C[0], 0, 0, 0));
	// キューに保存したijkを保存する
	processed_ijk.push_back(ijk(0, 0, 0));
	
	FOR(n, 0, K) {
		int i, j, k;
		long long taste;
		// 要素の参照
		taste = pqLL.top().taste;
		i = pqLL.top().i;
		j = pqLL.top().j;
		k = pqLL.top().k;
		// 要素の削除
		pqLL.pop();

		cout << taste << endl;

		// 要素の追加
		if ((i < X - 1) && (search_processed_ijk(processed_ijk, i + 1, j, k) == false)) {
			pqLL.push(cakeTotal(A[i + 1] + B[j] + C[k], i + 1, j, k));
			processed_ijk.push_back(ijk(i + 1, j, k));
		}
		if ((j < Y - 1) && (search_processed_ijk(processed_ijk, i, j + 1, k) == false)) {
			pqLL.push(cakeTotal(A[i] + B[j + 1] + C[k], i, j + 1, k));
			processed_ijk.push_back(ijk(i, j + 1, k));
		}
		if ((k < Z - 1) && (search_processed_ijk(processed_ijk, i, j, k + 1) == false)) {
			pqLL.push(cakeTotal(A[i] + B[j] + C[k + 1], i, j, k + 1));
			processed_ijk.push_back(ijk(i, j, k + 1));
		}
 	}

	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]
        self.sz = defaultdict(lambda:1)

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            size = self.sz[s1]+self.sz[s2]
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            s = self.find(x)
            self.sz[s] = size
            return True
        return False

    def size(self, x):
        s = self.find(x)
        return self.sz[s]
N,M,K = map(int,input().split())
u = UnionFind(N)
friend = [[] for _ in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    friend[A-1].append(B-1)
    friend[B-1].append(A-1)
    u.union(A-1,B-1)
block = [[] for _ in range(N)]
for i in range(K):
    C,D = map(int,input().split())
    block[C-1].append(D-1)
    block[D-1].append(C-1)
ans = [0]*N
for i in range(N):
    ans[i] = u.size(i)-1
    for f in friend[i]:
        if u.find(i)==u.find(f):
            ans[i] -= 1
    for b in block[i]:
        if u.find(i)==u.find(b):
            ans[i] -= 1
print(*ans)

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

ll X;

int main(void) {
  cin >> X;

  ll f = 0, x = X;
  while(x > 0) {
    f += x % 10;
    x /= 10;
  }

  cout << (X % f == 0 ? "Yes" : "No") << endl;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		long long tmp = 0;
		for(int j = 0; j < n; j++) {
			if(j < i) {
				tmp += a[0][j];
			}
			else if(j == i){
				tmp += a[1][j] + a[0][j];
			}
			else {
				tmp += a[1][j];
			}
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[10][10];
int fir(int p){
    int r;
    while(p!=0){
        r=p%10;
        p/=10;
    }
    return r;
} 
int32_t main()
{
    int n; cin>>n;
    for(int i=1;i<=n;++i)
        a[fir(i)][i%10]++;
    int s=0;
    for(int i=1;i<10;++i)
        for(int j=1;j<10;++j)
            s+=a[i][j]*a[j][i];
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	string str;

	bool s[26] = {false};

	cin >> str;
	for(int i=0 ; i<str.size() ; i++)
	{
		if(s[str[i]-'a'] == true)
		{
			cout << "no";
			return 0;
		}
		s[str[i]-'a'] = true;
	}
	cout << "yes";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner sc = new Scanner();

    internal static void Main(string[] args) {
        var N = sc.ArrayInt(2);

        WriteLine((N[0] - N[1]) + 1);
    }
}




class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

using namespace std;

const int maxx=10005;
int n,m,k;
//int a[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",min(a*b,c));
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s,t;
	std::cin >> s >> t;
	std::cout << t << s;
	return 0;
}


Measured memory_bytes: 256
import sys
import re
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    def is_ok(S):
        if re.match(r'(.?(AGC|GAC|ACG).?|A(.G|G.)C)',S):
            return False
        else:
            return True
    memo=[{} for _ in range(N+1)]
    def saiki(i,last3):
        if last3 in memo[i]:
            return memo[i][last3]
        if i==N:
            return 1
        c=0
        for s in 'ATGC':
            if is_ok(last3+s):
                c+=saiki(i+1,last3[1:]+s)
                c%=MOD
        memo[i][last3]=c
        return c
    print(saiki(0,'TTT'))
            
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 54620
A, B, K = map(int, input().split())

k = 0
max_divider = min(A, B)
for i in range(max_divider):
    d = max_divider-i
    if A % d == 0 and B % d == 0:
        k += 1
        if k == K:
            break

print(d)

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

namespace ABCTemplate_A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var a = new ProblemA();
		}
    }

    public class ProblemA
    {
        public ProblemA()
        {
            
            // 文字列の入力
            string s = Console.ReadLine();
            var splitted = s.Split(' ');
            var n = int.Parse(splitted[0]);
            var m = int.Parse(splitted[1]);

            var nc2 = 0;
            var mc2 = 0;

            if (n >= 2)
            {
                nc2 = n * (n - 1) / 2;
            }
            
            if (m >= 2)
            {
                mc2 = m * (m - 1) / 2;
            }
            

            //出力
            Console.WriteLine(nc2 + mc2);
        }
    }
}


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

int main() {
string c="aeiou";
string s;
cin>>s;
int count=0;
for(int i =0;i<5;i++){
    if(c[i]==s[0]){
        count++;
        break;
    }
}
if(count==1){
    cout<<"vowel";
}
else{cout<<"consonant";}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

	int cnt[51]{};
	for (int a, b, i = 0; i < M; ++i) {
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}

	for (int i = 1; i <= N; ++i)
		cout << cnt[i] << endl;

	return 0;
}

Measured memory_bytes: 256
n, q = gets.chomp.split.map(&:to_i)
str = gets.chomp[0..n]

counts = [0]
(1...n).each do |idx|
  counts[idx] = counts[idx - 1]
  counts[idx] += 1 if str[idx - 1] == "A" && str[idx] == "C"
end

q.to_i.times do
  l, r = gets.chomp.split.map(&:to_i)
  puts counts[r - 1] - counts[l - 1]
end


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

int main() {
 long long a,b; cin >> a >> b;
 
  if(a == 1 || b == 1) {
    cout << "1" << endl;
    return 0;
  }
  
 long long multi = a * b;
 int mod = multi % 2;
 if(mod == 0) {
   cout << multi / 2 << endl;
 } else {
   cout << (multi / 2) + 1 << endl;
 }
  
 return 0; 
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define k 10001
signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> A(n),B(n);
  for(int i=0;i<n;i++) cin>>A[i];
  int C[k];
  for(int i=0;i<k;i++) C[i]=0;
  for(int j=0;j<n;j++) C[A[j]]++;
  for(int i=1;i<k;i++) C[i]=C[i]+C[i-1];
  for(int j=n-1;j>=0;j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }
  for(int i=0;i<n;i++) cout<<B[i]<<" \n"[i==n-1];
  return 0;
}


Measured memory_bytes: 34172
#!/usr/bin/env pypy3

#import numpy as np
#import scipy, scipy.special

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5
from fractions import gcd

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################


N, K = input_ints()
S = input()

S2 = S[:K-1] + S[K-1].lower() + S[K:]
print(S2)


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <math.h>
#define LEN 1000000
using namespace std;

int f[50];
int fib(int);

int main(){
	f[0]=f[1]=1;
	int n;
	for(int i=2;i<50;i++){
		f[i]=-1;
	}
	cin >> n;
	cout << fib(n) <<endl;
}

int fib(int a){
	if(f[a]!=-1) return f[a];
	return f[a]=fib(a-1)+fib(a-2);
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var s = ReadText();
            return s.Count(x => x == '1');
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 26172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;

const int N = 1000 + 10;

int a[N*2], b[N*2], c[N*2];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i)
    {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        c[i] = -c[i];
    }

    ll dist[N];
    bool vis[N];
    memset(dist, 0x3f, sizeof dist);
    memset(vis, 0, sizeof vis);
    dist[1] = 0;

    for (int loop = 1; loop <= n - 1; ++ loop)
    {
        for (int i = 1; i <= m; ++i)
        {
            if (dist[b[i]] > dist[a[i]] + c[i])
            {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    ll ans = dist[n];
    for (int loop = 1; loop <= n ; ++ loop)
    {
        for (int i = 1; i <= m; ++i)
        {

            if (dist[b[i]] > dist[a[i]] + c[i])
            {
                dist[b[i]] = dist[a[i]] + c[i];
                vis[b[i]] = true;
            }

            if (vis[a[i]] == true)
            {
                vis[b[i]] = true;
            }
        }
    }
    if (vis[n])
        cout << "inf" << endl;
    else
        cout << -ans << endl;
    return 0;
}


Measured memory_bytes: 256