akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  auto solve = [&](ll t) {
    int ret = 0;
    ll cur = 1;
    while (t >= cur * 4) {
      t -= cur * 4;
      cur *= 3;
      ret += 2;
    }
    while (cur) {
      ret += t / cur;
      t %= cur;
      cur /= 3;
    }
    return ret;
  };

  ll t;
  while (cin >> t) {
    cout << solve(t) << '\n';
  }

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int K,N=50;
  cin>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++)A[i]=i+K/N-K%N;
  for(int i=0;i<K%N;i++)A[i]+=N+1;
  cout<<N<<endl;
  for(int i=0;i<N;i++)cout<<A[i]<<(i==N-1?'\n':' ');
}

Measured memory_bytes: 3564
#C問題
N = int(input())
D = list(map(int,input().split()))

D.sort()
left = 0
flag = 0
cir = [0 for i in range(24)]
for i in range(N):
    if D[i] == 0 or D[i] == 12:
        cir[D[i]] += 1
        if cir[D[i]] == 2:
            flag = 1
            break
    else:
        if left == 0:
            cir[D[i]]+=1
            left = 1
            if cir[D[i]] == 2:
                flag = 1
                break
        else:
            cir[24-D[i]]+=1
            left = 0
            if cir[24-D[i]] == 2:
                flag = 1
                break
                
if flag == 1:
    print(0)
else:
    MIN = 12
    point = [0]
    for i in range(24):
        if cir[i] == 1:
            point.append(i)
    point.append(0)
    #print(point)
    for i in range(len(point)-1):
        MIN = min(MIN,abs(point[i+1]-point[i]))
    print(MIN)

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<int> x(n), y(n), a(n);
  for(int i=0; i<n; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  int x_max, x_min, y_max, y_min;
  x_max = w; x_min = 0; y_max = h; y_min =0;
  
  for(int i=0; i<n; i++){
    if(a.at(i) == 1) x_min = max(x_min, x.at(i));
    if(a.at(i) == 2) x_max = min(x_max, x.at(i));
    if(a.at(i) == 3) y_min = max(y_min, y.at(i));
    if(a.at(i) == 4) y_max = min(y_max, y.at(i));
  }
  
  cout << max(x_max - x_min, 0) * max(y_max - y_min, 0) << endl;
  
  return 0;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;
  vector<ll> a(n),b(n);

  rep(i,n)
  {
    cin >> a[i];
    b[i] = a[i];
  }

  vsort(b);

  ll l = b[n/2-1];
  ll r = b[n/2];

  rep(i,n)
  {
    if(a[i] <= l)
      cout << r << endl;
    else
    {
      cout << l << endl;
    }
  }

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 5376
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func powIntMod(x, y, mod int) int {
	var res = 1
	for i := 0; i < y; i++ {
		res *= x
		res %= mod
	}
	return res
}

func main() {
	N := readInt()
	var ans int

	// A=0, C=1, G=2, T=3
	// dp[n文字][3文字前][2文字前][1文字前] = OK数
	// ?021, ?201, ?012, 0?21, 02?1 がNG
	var dp [105][4][4][4]int
	var mod int = 1000000007
	// 3は制約なし．文字列は333Sだと思って問題ない
	dp[0][3][3][3] = 1
	for n := 0; n < N; n++ {
		for i := 0; i < 4; i++ {
			for j := 0; j < 4; j++ {
				for k := 0; k < 4; k++ {
					for a := 0; a < 4; a++ {
						if (j == 0 && k == 2 && a == 1) ||
							(j == 2 && k == 0 && a == 1) ||
							(j == 0 && k == 1 && a == 2) ||
							(i == 0 && k == 2 && a == 1) ||
							(i == 0 && j == 2 && a == 1) {
							continue
						}
						dp[n+1][j][k][a] += dp[n][i][j][k]
						dp[n+1][j][k][a] %= mod
					}
				}
			}
		}
	}
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				ans += dp[N][i][j][k]
				ans %= mod
			}
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    if (n & 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) return (cout << "No" << endl, 0);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

int main(void){
  int N, A, B;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << endl;
  }
  else{
    cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  bool chk = false;
  string ans;
  cin >> N;
  for(int i = 0; i<=15;i++){
    for(int j = 0; j<=25;j++){
      if(i*7+j*4 == N){
    ans = "Yes";
        chk = true;
        break;
      }
    }
    if(chk){cout << ans << endl;break;}
  }
  if(!chk){cout << "No" << endl;}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b=sc.nextInt();
		int x = (a+b)/2+ (a+b)%2;
		System.out.print(x);
	}

}


Measured memory_bytes: 23764
#d
s = int(input())
mod = (10**9)+7
ans = 0
from scipy.special import comb
max_keta = s//3
for i in range(1,1+max_keta):
    last= s-(3*i)
    ans += (comb(last+1, i-1, exact=True,repetition=True))%mod
print(ans%mod)

Measured memory_bytes: 42400
#include<bits/stdc++.h>
#define exp exp69
using namespace std;
const int N=102;
const int VAL=502;
const int mod=1e9+7;
int exp[VAL][VAL],cnt[VAL],dp[VAL][VAL],inv[VAL],fact[VAL],ndp[VAL][VAL];
int mul(int x,int y){
	return (1ll*x*y)%mod;
}
void add(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
void sub(int &x,int y){
	x-=y;
	if(x<0){
		x+=mod;
	}
}
int binpow(int x,int y){
	int tich=1;
	while(y){
		if(y&1){
			tich=mul(tich,x);
		}
		x=mul(x,x);
		y>>=1;
	}
	return tich;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,sum,i,j,k,l,ans=1,z;
	cin>>n>>sum;
	for(i=1;i<=n;i++){
		cin>>j;
		cnt[j]++;
		ans=mul(ans,sum-j+1);
	}
	fact[0]=inv[0]=1;
	for(i=1;i<=sum;i++){
		fact[i]=mul(fact[i-1],i);
		inv[i]=binpow(fact[i],mod-2);
		exp[i][0]=1;
		for(j=1;j<=sum;j++){
			exp[i][j]=mul(exp[i][j-1],i);
		}
	}
	for(i=1;i<sum;i++){		//i blank space
		dp[i+1][sum-i]=fact[i+1];
		if(!(i&1)){
			dp[i+1][sum-i]=mod-dp[i+1][sum-i];
		}
	}
	for(i=0;i<=sum;i++){		//value
		for(j=0;j<=sum;j++){	//number of val
			if(j*i>sum){
				break;
			}
			for(k=j*i;k<=sum;k++){		//sum left
				for(l=j;l<=sum;l++){	//element left
					if(l*i>k){
						break;
					}
					z=mul(dp[l][k],inv[j]);
					if(cnt[i]){
						assert(k-l*(i-1)>=0);
						z=mul(z,exp[k-l*(i-1)][cnt[i]]);
					}
					assert(l-j>=0&&k-i*j>=0);
					add(ndp[l-j][k-i*j],z);
				}
			}
		}
		for(j=0;j<=sum;j++){		//sum left
			for(k=0;k<=sum;k++){		//element left
				if(k*i>j){
					break;
				}
				dp[k][j]=ndp[k][j];
				ndp[k][j]=0;
			}
		}
	}
	sub(ans,dp[0][0]);
	cout<<ans;
}

Measured memory_bytes: 3200
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

X, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

S, T = input().strip().split()

for i in range(X):
    print(S[i], end = "")
    print(T[i], end = "")
print("")

Measured memory_bytes: 3828
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

//int max(int a,int b){if(a>b){return a;}return b;}
//int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}

int main(){
  int d,e,i;
  double res,p,q;
  while(scanf("%d%d",&d,&e),d!=0){
    res=1234567890.0;
    for(i=0;i<=d;i++){
      p=i;q=d-i;
      res=dbmin(res,dbzt(e,sqrt(p*p+q*q)));
    }
    printf("%.12lf\n",res);
  }
  return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
ll n,v[N],qz0[N],qz1[N],qz2[N],hz0[N],res=1e18,a[N],b[N];
int main() {
	read(n);rep(i,1,n)read(v[i]);
	rep(i,1,n)qz0[i]=qz0[i-1]+v[i];
	per(i,n,1)hz0[i]=hz0[i+1]+v[i];
	rep(i,1,n)qz1[i]=qz1[i-1]+(v[i]==0?2:(v[i]&1));
	rep(i,1,n)qz2[i]=qz2[i-1]+((v[i]&1)^1);
	ll mn=1e18;
	rep(l,0,n){
		umin(mn,qz0[l]-qz1[l]);
		a[l]=qz1[l]+mn;
	}
	mn=1e18;
	per(r,n,0){
		umin(mn,hz0[r+1]+qz1[r]);
		b[r]=-qz1[r]+mn;
	}
	mn=1e18;
	rep(r,0,n)umin(mn,a[r]-qz2[r]),umin(res,qz2[r]+b[r]+mn);
	cout<<res;
	return 0;
}


Measured memory_bytes: 12544
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int

	fmt.Sscan(getNextLine(scanner), &n)
	bstart := 0
	aend := 0
	both := 0
	ans := 0
	for i := 0; i < n; i++ {
		s := getNextLine(scanner)
		if s[0] == 'B' {
			bstart++
		}
		if s[len(s)-1] == 'A' {
			aend++
		}
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			both++
		}
		for j := 1; j < len(s); j++ {
			if s[j-1] == 'A' && s[j] == 'B' {
				ans++
			}
		}
	}
	ans += minint(minint(bstart, aend), n-1)
	if bstart == aend && bstart == both && n > both && both > 0 {
		ans--
	}
	fmt.Println(ans)
}
func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 640
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val ans = Iterator.continually(io.StdIn.readLine)
    .take(n)
    .map(_.split(" "))
    .map(in => {
      val c = in(0).toInt - in(1).toInt - in(2).toInt
      if (c < 0 || (c & 1) == 1) false else true
    })
    .takeWhile(_ == true)
    .size

  println(if (ans == n) "Yes" else "No")
}

Measured memory_bytes: 43348
sx, sy, tx, ty = map(int,input().split())
ud = abs(sy-ty)+1
lr = abs(sx-tx)+1
ans = 'U'* (ud-1) + 'R'*lr + 'D'*ud + 'L'*lr+ 'UL'+ 'U'*ud + 'R'*lr + 'D'*ud + 'L'*(lr-1)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main( void ) 
{
	int i,j;
	
	for( i=1; i<=9; i++ ) {
		for( j=1; j<=9; j++ ) {
			printf( "%dx%d=%d\n", i, j, i*j );
		}
	}

	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include <stdlib.h>
int main() {
    int x,n ,_;
    _ = scanf("%d %d",&x,&n);
    int p[102];
    for(int i = 0; i <= 101; i++) {
        p[i] = 0;
    }
    for(int i = 0;i < n; i++) {
        int a;
        _ = scanf("%d", &a);
        p[a] = 1;
    }
    int ans = 0;
    int min = 1000;
    for (int i = 0; i <= 101; i++) {
        if (p[i] == 0) {
            if (min > abs(x-i)) {
                min = abs(x-i);
                ans = i;
            }
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1736
N,X=map(int,input().split())
L=[int(i) for i in input().split()]
D=[0]*(N+1)
cnt=1
for i in range(1,N+1):
  D[i]=D[i-1]+L[i-1]
  if D[i]<=X:
    cnt+=1
  else:
    break
print(cnt)

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);




void solve(int testCase){

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

    vector < int > a(n);
    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    vector < int > dp(n , 2e9);
    dp[0] = 0;
    for(int i = 0 ; i < n ; i ++){
            for(int j = i-1 ; j >= i - k && j >= 0 ; j --){
                        dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j]));
            }
    }

    printf("%d\n" , dp[n-1]);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

const int M = 75;
int f[M + 5][M + 5][M + 5];
bool g[M + 5][M + 5][M + 5];
int A, B, C;

int go(int i, int k, int j)
{
    if(i < A || k < B || j < C)
    {
        return inf;
    }
    
    if(!g[i][k][j])
    {
        g[i][k][j] = true;
        if(i == A && k == B && j == C)
        {
            f[i][k][j] = 0;
        }
        else
        {
            f[i][k][j] = inf;
            f[i][k][j] = min(f[i][k][j], go(i - 1, k - 1, j) + 1);
            f[i][k][j] = min(f[i][k][j], go(i - 1, k, j - 1) + 1);
            f[i][k][j] = min(f[i][k][j], go(i, k - 1, j - 1) + 1);
            f[i][k][j] = min(f[i][k][j], go(i - 2, k, j) + 1);
            f[i][k][j] = min(f[i][k][j], go(i, k - 2, j) + 1);
            f[i][k][j] = min(f[i][k][j], go(i, k, j - 2) + 1);
        }
    }
    
    return f[i][k][j];
}

void solve()
{
    for(int i = 0; i < M; i++)
    {
        for(int k = 0; k < M; k++)
        {
            for(int j = 0; j < M; j++)
            {
                g[i][k][j] = false;
            }
        }
    }
    
    cin >> A >> B >> C;

    int ans = inf;
    for(int i = 0; i < M; i++)
    {
        ans = min(ans, go(i, i, i));
        //cout << i << " " << go(i, i, i) << "\n";
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    
    return 0;
}



Measured memory_bytes: 2560
var
	n,i,f:Longint;
	s,m:int64;
	a,b:String[52];
begin
	readln(n);
	readln(a);
	readln(b);
	s:=1;
	m:=1000000007;
	i:=1;
	while i<=n do begin
		if a[i]=b[i] then begin
			if f=0 then s:=s*3 mod m else if f=1 then s:=s*2 mod m;
			f:=1;
		end else begin
			if f=0 then s:=s*6 mod m else if f=1 then s:=s*2 mod m else s:=s*3 mod m;
			f:=2;
			inc(i);
		end;
		inc(i);
	end;
	writeln(s);
end.


Measured memory_bytes: 128
n = int(input())
ac = "AC"
wa = "WA"
tle = "TLE"
re = "RE"

ans = [0, 0, 0, 0]
for _ in range(n):
    a = input()
    if (a == ac):
        ans[0] += 1
    if (a == wa):
        ans[1] += 1
    if (a == tle):
        ans[2] += 1
    if (a == re):
        ans[3] += 1

print("AC x ",ans[0])
print("WA x ",ans[1])
print("TLE x ",ans[2])
print("RE x ",ans[3])


Measured memory_bytes: 9216
#include<iostream>
using namespace std;
#define max 10000

void countingsort(int a[], int b[],int n) {
    int c[max];
	for (int i = 0; i < max; i++) {
		c[i] = 0;
	}
	
	for (int i = 0; i < n; i++) {
		c[a[i]]++;
	}
	
	for (int i = 0; i < max; i++) {
		if(i > 0) c[i] += c[i - 1];
	}

	for (int i = n-1; i > -1; i--) {
		b[c[a[i]]-1] = a[i];
		c[a[i]]--;
	}
}

int main()
{
	int n;
	cin >> n;
	int a[2000000];
	int b[2000000];

	for (int i = 0; i < 2000000; i++) {
		b[i] = 0;
	}

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

	countingsort(a, b, n);

	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << b[i];
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 18740
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200011];
int B[200011];
bool save(int S, int W) {
    int left = 1, right = W;
    for (int i=N; i--;) {
	left = max(1, min(left, left-B[i]));
	right = min(W, max(right, right-B[i]));

	left = max(left, left-A[i]);
	right = min(right, right-A[i]);
	if (right < left) return false;
    }

    return left <= S && S <= right;
}

void press(char *s, int *a, char L, char R) {
    REP (i, N) {
	if (s[i] == L) a[i] = -1;
	else if (s[i] == R) a[i] = 1;
	else a[i] = 0;
    }
}

int H, W;

char S[200011], T[200011];

void MAIN() {
    scanf("%d%d%d", &H, &W, &N);
    int Sr, Sc;
    scanf("%d%d", &Sr, &Sc);
    scanf("%s%s", S, T);

    press(S, A, 'L', 'R');
    press(T, B, 'L', 'R');

    bool yes = true;
    yes = yes && save(Sc, W);

    press(S, A, 'U', 'D');
    press(T, B, 'U', 'D');

    yes = yes && save(Sr, H);

    puts(yes? "YES": "NO");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define brep1(i,n) for(int i=n;i>=1;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

int main(void){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> baito;
    rep(i,n){
        int pay,day;
        cin >> day >> pay;
        baito.emplace_back(day,pay);
    }
    sort(baito.begin(),baito.end());
    priority_queue<int> candidate;
    ll ans = 0;
    ll baito_num = 0;
    rep1(date,m+1){
        while(baito_num <= n-1 && baito[baito_num].first == date){
            candidate.push(baito[baito_num].second);
            baito_num++;
        }
        if(!candidate.empty()){
            ans += candidate.top();
            candidate.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n;
    string s;
    int i;
    int ans = 1;

    cin >> n >> s;

    rep(i, 1, n)
    {
        if (s[i] == s[i - 1])
        {
        }
        else
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    int k;cin >> k;
    string s;cin >> s;
    int n = s.size();
    if(n<= k)cout << s << endl;
    else {
        string res = "";
        rep(i,k){
            res += s[i];
        }
        res += "...";
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            int t=sc.nextInt();
            if(t==0){
                break;
            }
            int n=sc.nextInt();
            int cnt=0;
            for(int i=0;i<n;i++){
                int a=sc.nextInt();
                int b=sc.nextInt();
                cnt+=b-a;
            }
            if(t<=cnt){
                System.out.println("OK");
            }else{
                System.out.println(t-cnt);
            }
        }
    }
}


Measured memory_bytes: 31404
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
 

def solve(a,b,c,d):
  if abs(a-b) <= d and abs(b-c) <= d:
    return True
  elif abs(a-c) <= d:
    return True
  else:
    return False

a,b,c,d = map(int, sys.stdin.readline().rstrip().split())
if solve(a,b,c,d):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int sx,tx,sy,ty;
	cin >> sx >> sy >> tx >> ty;
	for(int i=0; i<tx-sx; i++) cout << "R";
	for(int i=0; i<ty-sy; i++) cout << "U";
	for(int i=0; i<tx-sx; i++) cout << "L";
	for(int i=0; i<ty-sy; i++) cout << "D";
	cout << "D";
	for(int i=-1; i<tx-sx; i++) cout << "R";
	for(int i=-1; i<ty-sy; i++) cout << "U";
	cout << "L";
	cout << "U";
	for(int i=-1; i<tx-sx; i++) cout << "L";
	for(int i=-1; i<ty-sy; i++) cout << "D";
	cout << "R";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  int X ;
  cin >> N >> X ;

  int m[N];
  int ans = N ;
  REP(i,N){
    cin >> m[i];
    X -= m[i]; 
  }

  sort(m,m+N);

  if (DEBUG){
    REP(i,N){
      cout << m[i] << endl;
      cout << X << endl;
      cout << X/m[0] << endl;
    }
  }
  ans += X/m[0];
  cout << ans << endl;



  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    if(k%2)cout<<b-a<<endl;
    else cout<<a-b<<endl;

}


Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll 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; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

ll dp[103][100003];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,W;
    cin>>n>>W;
    ll w[1000],v[1000];
    for (int i = 1; i <=n; ++i)
    {
    	cin>>w[i]>>v[i];
    }
    for (int i = 1; i <=n; ++i)
    {
    	dp[i][w[i]]=v[i];
    }
    for (int i = 1; i <=n; ++i)
    {
    	for (int j = 1; j <=W ; ++j)
    	{
    		if(j>=w[i])
    		{
    			dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
    		}
    		else
    		{
    			dp[i][j]=dp[i-1][j];
    		}

    		// cout<<i<<" "<<j<<" "<<dp[i][j]<<'\n';
    	}
    }
    cout<<dp[n][W]<<'\n';
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a(N);
    
    int len = 1e5;
    vector<int> vals(len);

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        vals[a[i]]++;
    }

    int min = *min_element(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());
    
    int maxCount = 0;
    for(int x = min; x <= max; x++){
        int left = (x > 0) ? vals[x-1] : 0;
        int right = (x < len - 1) ? vals[x+1] : 0;
        int count = left + vals[x] + right;
        if(count > maxCount) maxCount = count;
    }

    cout << maxCount << endl;
    return 0;
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define for0(i,n) for(int i=0;i<n;i++)
#define rep(i,s,n) for(int i=s;i<n;i++)
#define sp <<" "<<					// giving space
#define MOD 1000000007				// for mod
#define ll_max 1000000000000000000
#define ll long long
#define ld long double
#define BOOST ios_base::sync_with_stdio ( false ); cin.tie ( nullptr ); cout.tie ( nullptr );
using namespace std;
// Vector
#define vi vector<int>					//integer vector
#define vll vector<ll>
#define pb push_back				//vector element insertion
#define pf push_front
#define er(v,i) v.erase(v.begin()+i)			// erase ith element in a vector
#define erng(v,x) v.erase(v.begin(),v.begin()+x)       	// delete a range in array

//Stack
/*  stack<int> s;						//declaring stack
s.push(1)						// enter  element in stack
s.top()							//returns top element in stack
s.pop()							//removes top element in  stack
*/
// pair
#define pii pair<int,int>					//pair integers
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)			// entering pair element in vector(size not defined)

//Hashmap
/* map<string,string> a;				//declaration
a[“abc”]=”xyz”;					// element entry in map;
gquiz1.insert(pair<int, int>(1, 40));
map<string,string>::iterator itr;			//iterating map
for (itr = a.begin(); itr!=a.end(); itr++){
    cout <<(*itr).first  << itr->second <<endl;
  }
  itr = companies.find("abc");		//finding element in map
  cout << itz->second;

//*/

ld dp[3005];

int main()
{
   int n;
   cin>>n;
   vector<ld> a(n);

   for0(i,n)cin>>a[i];
   dp[0]=1;
   rep(i,1,n+1)
   {

       for(int j=i;j>=0;j--)
       {
           dp[j]=dp[j]*(1-a[i-1]);
           if(j)dp[j]=dp[j]+(dp[j-1]*a[i-1]);
       }
   }
   ld s=0;
   rep(i,n/2+1,n+1)s+=dp[i];
   cout<<fixed<<setprecision(12)<<s<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll n,m;
vector<ll> a;

int main(){
    //考察
    /*
    Aの後ろにあるBCの数、Bの後ろにあるCの数
    結局DPじゃないか？
    Aもまだみてない、Aまでみた、Bまでみた
    の状態と
    i文字目まで見たっていう状態を持つDPな気がする
     */
    string s;
    cin>>s;
    ll n=s.size();
    ll dp[n+1][4]={};
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        if(s[i]=='?'){
            dp[i+1][0]=3*dp[i][0]%mod;
            dp[i+1][1]=3*dp[i][1]%mod;
            dp[i+1][2]=3*dp[i][2]%mod;
            dp[i+1][3]=3*dp[i][3]%mod;

        }
        else{
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1];
            dp[i+1][2]=dp[i][2];
            dp[i+1][3]=dp[i][3];
        }
        if(s[i]=='A'){
            dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod;
        }
        else if(s[i]=='B'){
            dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mod;
        }
        else if(s[i]=='C'){
            dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mod;
        }
        else{//?
            dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod;
            dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mod;
            dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mod;
        }
    }

    cout<<dp[n][3]<<endl;
    return 0;
}

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

int main() {
  int N,M,H;
  int SUM = 0;
  cin >> N;
  H = N;
  
  for (int i=0; i< 9; i++) {
    SUM += N % 10;
    N = N / 10;
   
  }
 if (H % SUM == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, d, x, y, cnt;

int main() {
	cin >> n >> d;
	for (int i = 1; i <= n; i++) {
		cin >> x >> y;
		if (d * d >= x * x + y * y)
			cnt++;
	}
	cout << cnt;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


int main() {

    ll W , H, N;

    cin >> W >> H >> N;

    ll R = 0, L = W, B = 0, T = H, x, y, a;

    rep(i, N) {
        cin >> x >> y >> a;

        if (a == 1) {
            R = max(x, R);
        }
        if (a == 2) {
            L = min(x, L);
        }
        if (a == 3) {
            B = max(y, B);
        }
        if (a == 4) {
            T = min(y, T);
        }

    }

    ll ans;

    ans = max((ll)0, L - R) * max((ll)0, T - B);

    cout << ans;

    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var M = cin.ReadInt;
            var X = cin.ReadInt;
            var A = cin.ReadIntArray(M);

            var left = A.Where(i => i < X).Count();
            var right = A.Where(i => i > X).Count();

            if(left <= right){
                WriteLine(left);
            }else{
                WriteLine(right);
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11348
n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
     
#print(cards)
 
for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)


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

const int MAX_N  = 3009;
int N, T;
int A[MAX_N], B[MAX_N];

void solve()
{
	vector<pair<int,int>> v;
	for(int i=0;i<N;++i) v.emplace_back(A[i],B[i]);
	sort(v.begin(),v.end());
    vector< int > dp(T + 1);
    for(const auto &p : v) {
        for(int k = T - 1; k >= 0; k--) {
            dp[min(T, k + p.first)] = max(dp[min(T, k + p.first)],  dp[k] + p.second);
        }
    }
    cout << dp.back() << endl;
}

int main()
{
	cin >> N >> T;
	for(int i=0;i<N;++i) cin >> A[i] >> B[i];
	solve();
	return 0;
}

Measured memory_bytes: 3692
import sys
import os
sys.setrecursionlimit(100000)

def gcd(a,b):
    if b>=a:
        a,b = b,a
    if b<= 0:
        return a
    return gcd(b,a%b)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

A, B = map(int,input().split())
P = factorize(gcd(A,B))
P = set(P)

print(len(P)+1)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define EPS (1e-10)
double x[1050], y[1050];
int n;

int count(int a, int b){
    double tx = (x[a] + x[b]) / 2;
    double ty = (y[a] + y[b]) / 2;
    double dx = (y[a] - y[b]);
    double dy = (x[b] - x[a]);
    double rat =  sqrt(1 - (dy * dy + dx * dx) / 4)/ hypot(dx, dy);
    dx *= rat;
    dy *= rat;
    tx += dx;
    ty += dy;
    int res = 0;
    for(int i = 0;i < n;i++){
	if(hypot(x[i] - tx, y[i] - ty) <= 1 + EPS)res++;
    }
    return res;
}

int main(){
    while(1){
    int res = 1;
	cin >> n;
	if(n == 0)return 0;
	for(int i = 0;i < n;i++){
	    scanf("%lf,%lf", &x[i], &y[i]);
	}
	for(int i = 0;i < n;i++){
	    for(int j = i + 1;j < n;j++){
		if(hypot(x[i] - x[j], y[i] - y[j]) <= 2 + EPS){
		    res = max(res, count(i, j));
		    res = max(res, count(j, i));
		}
	    }
	}
	cout << res << endl;
    }
}

Measured memory_bytes: 1288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	String N = input.next();
      	int[] ns = new int[9];
      	for (int i = 0; i < 9; i++) {
          	int num = i + 1;
        	ns[i] = num * 100 + num * 10 + num;
        }
      	int ans = 1000;
      	
      	for (int i = 0; i < 9; i++) {
          if (ns[i] >= Integer.parseInt(N) && ns[i] < ans) {
              ans = ns[i];
          }
        }
		System.out.print(ans);

    }
  	
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

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

  ll t; cin >> t;
  if(t == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll now = 1;
  ll su = 1;
  ll cnt = 1;
  ll ans = LINF;
  while(su <= t) {
    ll tmp = t - su * 2 + 1;
    //cout << tmp << endl;
    if(tmp < 0) {
      break;
    }
    ll div = now * 3;
    bool ok = true;
    ll nowans = cnt * 2 - 1;
    while(div > 0) {
      ll tmp2 = tmp / div;
      //cout << div << " " << tmp2 << endl;
      nowans += tmp2;
      tmp = tmp % div;
      div /= 3;
    }
    ans = min(ans, nowans);
    //cout << now << ":" << nowans << endl;
    now *= 3;
    su += now;
    cnt++;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int mod = 998244353;
constexpr ll inf = 1e15;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

struct RangeMaximumQuery {
  using type = int;
  static type id() { return -INT_MAX; }
  static type op(const type &l, const type &r) { return std::max(l, r); }
};

template <typename M>
class SegmentTree {
  using T = typename M::type;
  int n;
  std::vector<T> node;

 public:
  // Monoid::id 初期化
  SegmentTree(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    node.resize(2 * n, M::id());
  }
  // x 番目を val に更新
  void update(int x, T val) {
    x += n;
    node[x] = val;
    while (x >>= 1) {
      node[x] = M::op(node[2 * x], node[2 * x + 1]);
    }
  }
  // v[x] を M::op(v[x], val) に更新
  void operation(int x, T val) {
    x += n;
    node[x] = M::op(node[x], val);
    while (x >>= 1) {
      node[x] = M::op(node[2 * x], node[2 * x + 1]);
    }
  }
  // [a, b) の op
  T query(int l, int r) {
    l += n;
    r += n;
    T retl = M::id(), retr = M::id();
    while (l < r) {
      if (l & 1) retl = M::op(retl, node[l++]);
      if (r & 1) retr = M::op(node[--r], retr);
      l >>= 1;
      r >>= 1;
    }
    return M::op(retl, retr);
  }
};

const int MAX_N = 200010;
SegmentTree<RangeMaximumQuery> seg(MAX_N);

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

  int n;
  cin >> n;
  vector<P> ps;
  for (int i = 0; i < n; i++) {
    ll x, d;
    cin >> x >> d;
    ps.push_back(P(x, d));
  }
  sort(ps.begin(), ps.end());
  vector<ll> x(n), d(n);
  for (int i = 0; i < n; i++) {
    x[i] = ps[i].first;
    d[i] = ps[i].second;
  }
  // seg[i] := i を倒すとどこまで倒れるか
  x.push_back(inf);
  vector<ll> dp(n + 1);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    seg.update(i, i);
    auto itr = lower_bound(x.begin(), x.end(), x[i] + d[i]);
    int pos = distance(x.begin(), itr);
    auto ma = seg.query(i, pos);
    seg.operation(i, ma);
    dp[i] = (dp[i + 1] + dp[ma + 1]) % mod;
  }
  cout << dp[0] << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int maxn = 2e5 + 5, base = 131;
const ll llinf = 1e18;

int BIT[maxn];

void upd(int i, int v)
{
  for(; i < maxn; i += i & -i)
    BIT[i] += v;
}

int sum(int i)
{
  int res = 0;
  for(; i; i -= i & -i)
    res += BIT[i];
  return res;
}

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  int n, k; cin >> n >> k;
  vector<ll> a(n);
  for(auto & x : a) cin >> x, x -= k;
  for(int i = 1; i < n; ++i)
    a[i] += a[i - 1];
  vector<ll> v = a;
  v.pb(0);
  sort(v.begin(), v.end());
  for(auto & x : a){
    x = lower_bound(v.begin(), v.end(), x) - v.begin() + 1;
  }
  int z = lower_bound(v.begin(), v.end(), 0) - v.begin() + 1;
  upd(z, 1);
  ll res = 0;
  for(auto & x : a){
    res += sum(x);
    upd(x, 1);
  }
  cout << res;
}


Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = new string[n];
            for (int i = 0; i < n; i++)
            {
                str[i] = Console.ReadLine();
            }
            for (int i = 0; i < n; i++)
            {
                string s = str[i];
                char[] cs = s.ToCharArray();
                Array.Sort(cs);
                str[i] = new string(cs);
            }

            Array.Sort(str);

            long res = 0;
            long cnt = 0;
            for (int i = 0; i < n - 1; i++)
            {
                if (str[i].Equals(str[i+1]))
                {
                    cnt++;
                } else
                {
                    if (cnt == 0)
                    {
                        continue;
                    }
                    long conbi = ((cnt + 1) * cnt) / 2;
                    res += conbi;
                    cnt = 0;
                }
            }
            if (cnt > 0)
            {
                long conbi = ((cnt + 1) * cnt) / 2;
                res += conbi;
            }

            System.Console.WriteLine(res);
        }
    }
}



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

using namespace std;

int main() {

	int n,k;
	cin >> n >> k;

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

	int l;
	int r;
	int mid=0;
	r = accumulate(w.begin(), w.end(),0);
	l = 0;

	while (l!=r) {
		mid = (l + r) / 2;

		int counter = 0;
		int acc = 0;
		for (int i = 0; i < n; i++) {
			acc += w[i];
			if (acc > mid) {
				counter++;
				acc = 0;
				if (counter >= k) {
					if (r - l != 1) {
						l = mid;
					}
					else {
						l = mid + 1;
						mid = l;
					}
					break;
				}
				i--;
			}
			if (i == n - 1) {
				r = mid;
			}
		}

	}
	cout << mid << endl;
}


Measured memory_bytes: 3112
#include<iostream>

using namespace std;

int main(){
    int a,b;
    int s;
    cin >> s;
    a = (s-(s%100))/100;
    b = (s-a*100);
    bool ym=false, my=false;

    if(a>=1&&a<=12) my = true;
    if(b>=1&&b<=12) ym = true;

    if(my&&ym) cout << "AMBIGUOUS" << endl;
    else if(my) cout << "MMYY" << endl;
    else if(ym) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}



Measured memory_bytes: 256