akhauriyash/Code-Regression huggingface dataset:
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
			int a = ni(), b = ni();
			int	ct = 1;
			int	step = 0;
				while (ct < b) {
				    ct -= 1;
				    ct += a;
				    step += 1;
				}
				out.print(step);
	}
		
		
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;


int N,M,Q;
int L[200010];
int R[200010];
int p[100010];
int q[100010];

int acc[1000][1000];

int main () {

    cin >> N >> M >> Q;
    REP(i,M) cin >> L[i] >> R[i];
    REP(i,Q) cin >> p[i] >> q[i];

    for (int i = 0; i < M; i++) {
        for (int s = 0; s <= L[i]; s++) {
            acc[s][R[i]]++;
        }
    }
    
    REP(j,800) REP(i,800) acc[j][i + 1] = acc[j][i] + acc[j][i + 1];

    REP(i,Q) {
        cout << acc[p[i]][q[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 7168
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

bool helper(ll ansReq, vector<ll>&v, ll k){
    int ans = 0;
    for(auto& ele: v){
        ll temp=((ele+ansReq-1)/ansReq);
        ans+=(temp-1);
    }
    return ans<=k;
}

int main(){
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<ll> v(n);
    ll h=0;
    for(ll i=0; i<n; i++){
        cin>>v[i];
        h = max(h, v[i]);
    }
    ll l=1;
    while(l<h){
        ll mid = (l+h)/2;
        if(helper(mid, v, k)){
            h = mid;
        }
        else{
            l = mid+1;
        }
    }
    cout<<l<<endl;
    return 0;
}






Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

#define Fail return puts("No"),0;
const int N=3e5+5;
int n,p[N],tr[N];
inline void add(int x,int v){for(;x<=n;x+=x&-x)tr[x]+=v;}
inline int query(int x){int ans=0;for(;x;x-=x&-x)ans+=tr[x];return ans;}

int main(){
    //freopen("in.in","r",stdin);
    REP(i,1,n=read())p[i]=read();
    ll a=0,s=0;
    for(int i=(n&1?n:n-1);i>0;i-=2){
	if(!(p[i]&1))Fail;
	a+=query(p[i]);
	add(p[i],1);
    }
    memset(tr,0,sizeof tr);
    for(int i(n&1?n-1:n);i>0;i-=2){
	if(p[i]&1)Fail;
	a+=query(p[i]);
	add(p[i],1);
    }
    memset(tr,0,sizeof tr);
    DREP(i,n,1)s+=query(p[i]),add(p[i],1);
    return puts(a*3==s?"Yes":"No"),0;
}


Measured memory_bytes: 2560
char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c-d[i]?putchar(c),*G++:r[i++];exit(0);}

Measured memory_bytes: 524
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
  
}


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

using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
int n,q,tot;
ll res[MAXN],dat[MAXN],cnt[MAXN];

int Query(ll x,int r)
{
	int ret=-1,l=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(dat[mid]<=x) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return ret;
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=q;i++) scanf("%lld",&dat[i]);
	dat[0]=n;
	for(int i=1;i<=q;i++)
	{
		while(tot>=0&&dat[i]<dat[tot]) tot--;
		dat[++tot]=dat[i];
	}
	
	cnt[tot]=1;
	for(int i=tot;i>=0;i--)
	{
		ll k=dat[i],pos=Query(k,i-1);
		while(pos>=0)
		{
			cnt[pos]+=(k/dat[pos])*cnt[i];
			k=k%dat[pos];pos=Query(k,pos-1);
		}
		res[1]+=cnt[i];res[k+1]-=cnt[i];
	}
	for(int i=1;i<=n;i++)
		res[i]+=res[i-1],printf("%lld\n",res[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    char c;
    cin >> c;

    cout << char(c + 1) << endl;    
    return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
a = []

H.times do |i|
  a[i] = gets.chomp
end

puts "#" * (W + 2) # 文字列オブジェクトを指定した回数繰り返す

a.each do |word|
  puts ("#" + word + "#").to_s
end

puts "#" * (W + 2) # # 文字列オブジェクトを指定した回数繰り返す

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

struct _Node{
  int key;
  struct _Node *next;
  struct _Node *prev;
};
typedef struct _Node Node;

Node *nil;

void insert(int key) {
  Node *n;
  n = (Node *)malloc(sizeof(Node));
  n->key = key;
  n->next = nil->next;
  nil->next = nil->next->prev = n;
  n->prev = nil;
}

void deleteNode(Node *n) {
  n->prev->next = n->next;
  n->next->prev = n->prev;
}

void delete(int key) {
  Node *n;
  for (n = nil->next; n != nil; n = n->next) {
    if (n->key == key) {
      deleteNode(n);
      return;
    }
  }
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

int main() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  int i, key, N;
  char *command;
  command = (char *)malloc(sizeof(char) * 12);

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf(" %s", command);
    switch(*command) {
    case 'i': scanf(" %d", &key); insert(key); break;
    default :
      switch(*(command + 6)) {
      case 'F': deleteFirst(); break;
      case 'L': deleteLast(); break;
      default: scanf(" %d", &key); delete(key); break;
      }
    }
  }

  Node *node;
  for (node = nil->next;; node = node->next) {
    if (node->next == nil) {
      printf("%d\n", node->key);
      break;
    }
    printf("%d ", node->key);
  }
  return 0;
}



Measured memory_bytes: 36056
N = int(input())
m = 10**9 + 7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res
s = pos(10, N, m)
t = pos(9, N, m)
u = pos(8, N, m)
ans = s + u - t - t
ans = ans % m
print(ans)

Measured memory_bytes: 9192
n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    a = pow(pow(x3-x2, 2) + pow(y3-y2, 2), 0.5)
    b = pow(pow(x1-x3, 2) + pow(y1-y3, 2), 0.5)
    c = pow(pow(x2-x1, 2) + pow(y2-y1, 2), 0.5)
    cosA = (b**2+c**2-a**2) / (2*b*c)
    sinA = 1-cosA**2
    r = a / pow(sinA, 0.5) / 2
    a, b, c = x1-x2, y1-y2, -(x1**2 + y1**2) + (x2**2 + y2**2)
    d, e, f = x2-x3, y2-y3, -(x2**2 + y2**2) + (x3**2 + y3**2)
    l = (c*e - b*f) / (e*a - b*d)
    m = (c*d - a*f) / (b*d - a*e)
    print("{0:.3f} {1:.3f} {2:.3f}".format(-l/2, -m/2, r))

Measured memory_bytes: 7496
n,m=map(int,input().split())
es=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    es.append((a-1,b-1,-c))

def bellman_ford(s,v,e,es):
    #s:始点　v:頂点数　e:辺の数　es:[s,t,c]
    d = [float("inf")]*v
    d[s] = 0

    for i in range(n):
        for p,q,r in es:
            if d[p] != float("inf") and d[q] > d[p] + r:
                d[q] = d[p] + r
                if i==n-1 and q==n-1:
                    print("inf")
                    exit()
    return d

d=bellman_ford(0,n,m,es)
print(-d[n-1])


Measured memory_bytes: 45272
using System;

namespace B
{
    class Calc
    {
        public void dis(int[,] gragh, int n)
        {
            int[] d = new int[n];
            int[] pi = new int[n];
            string[] color = new string[n];
            int i, mincost = int.MaxValue, u = 0;
            for (i = 0; i < n; i++)
            {
                d[i] = int.MaxValue;
                pi[i] = -1;
                color[i] = "WHITE";
            }
            d[0] = 0;
            while (true)
            {
                mincost = int.MaxValue;
                for (i = 0; i < n; i++)
                {
                    if (color[i] != "BLACK" && d[i] < mincost)
                    {
                        mincost = d[i];
                        u = i;
                    }
                }
                if (mincost == int.MaxValue)
                {
                    break;
                }
                color[u] = "BLACK";
                for (int v = 0; v < n; v++)
                {
                    if (color[v] != "BLACK" && d[u] + gragh[u, v] < d[v] && gragh[u, v] != -1)
                    {
                        pi[v] = u;
                        d[v] = d[u] + gragh[u, v];
                    }
                }
            }
            for (int j = 0; j < n; j++)
            {
                Console.WriteLine(j + " " + d[j]);
            }
        }
    }

    class B
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            int n = int.Parse(input1), i, j;
            int[,] gragh = new int[n, n];
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < n; j++)
                {
                    gragh[i, j] = -1;
                }
            }
            for (i = 0; i < n; i++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                for (j = 0; j < int.Parse(input2[1]); j++)
                {
                    gragh[i, int.Parse(input2[2 + j * 2])] = int.Parse(input2[3 + j * 2]);

                }
            }
            Calc check = new Calc();
            check.dis(gragh, n);
        }
    }
}



Measured memory_bytes: 15940
S = input()
mod = 10**9 + 7
dic = {'': 1, 'A': 0, 'B': 0, 'C': 0}
for s in S:
    if s == 'A':
        dic[s] += dic['']

    elif s == 'B':
        dic[s] += dic['A']

    elif s == 'C':
        dic[s] += dic['B']

    elif s == '?':
        dic['C'] = dic['C'] * 3 + dic['B']
        dic['B'] = dic['B'] * 3 + dic['A']
        dic['A'] = dic['A'] * 3 + dic['']
        dic[''] *= 3

    dic[''] %= mod
    dic['A'] %= mod
    dic['B'] %= mod
    dic['C'] %= mod

print(dic['C']%mod)


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

int main () {
  unsigned long long x , y ;
  cin >> x >> y ;
  long long ans = 0 ;
  for(int i = 0 ;; i++ ){
    if(y>=x*(long long)pow(2,i)) ans = i ;
    else break ;
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
      int[] a = new int[N];
      double sum=0;
      for(int i=0;i<N;i++){
       a[i] = sc.nextInt();
       sum+=a[i];
      }
      double ave = sum/N;
      double min =100;
      int ans = 0;
      for(int i=0;i<N;i++){
        double d = Math.abs((double)a[i]-ave);
        if(d<min){
          min=d;
          ans=i;
        }
      }
      	System.out.println(ans);
    }
}

Measured memory_bytes: 35980
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int w,h,n;
    cin >> w >> h >> n;
    int ww = 0, hh = 0;
    rep(i,n){
        int x,y,a;
        cin >> x >> y >> a;
        if(a == 1){
            ww = max(ww,x);
        }
        if(a == 2){
            w = min(w,x);
        }
        if(a == 3){
            hh = max(hh,y);
        }
        if(a == 4){
            h = min(h,y);
        }
    }
    //cout << ww << " " << w << endl;
    //cout << hh << " " << h << endl;
    if(h <= hh || ww >= w){
        cout << 0 << endl;
    }else cout << (hh-h)*(ww-w) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    int size = s.length();
    if(size > k){
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }else{
        cout << s << endl;
    }
}

Measured memory_bytes: 3692
#include<stdio.h>

char counter[10000100];

int main(){
  int a,b,n,i,count;
  do{
    scanf("%d %d %d",&n,&a,&b);
    if(a==0&&b==0&&n==0) break;
    for(i=a;i<=n;i+=a) counter[i]++;
    for(i=0,counter[b]++;i<=n;i++)
      if(counter[i]&&i+b<=n) counter[i+b]++;
    for(i=1,count=0;i<=n;i++)
      if(!counter[i]) count++;
    printf("%d\n",count);
    for(i=0;i<=n;i++) counter[i]=0;
  }while(1);
  return 0;
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

d = list(aa - bb for aa, bb in zip(a, b))
d = sorted(d)

p = tuple(filter(lambda x: x >= 0, d))
p = sorted(p, reverse=True)
m = tuple(filter(lambda x: x < 0, d))

s = sum(m)

i = 0
while s < 0 and i < len(p):
    s += p[i]
    i += 1

print(len(m) + i if s >= 0 else -1)


Measured memory_bytes: 18292
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-17(Sun)
   note   
**********************************************************************/

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) cout << 1 << endl;
  else if(b == 0) cout << 2 << endl;
  else if(c == 0) cout << 3 << endl;
  else if(d == 0) cout << 4 << endl;
  else if(e == 0) cout << 5 << endl;
  return 0; 
}

Measured memory_bytes: 3568
def jubge_winner():
    # 弱い順の数字をリスト化
    weak_strong_trump = [2,3,4,5,6,7,8,9,10,11,12,13,1]
    # ドロー
    A, B = map(int, input().split())
    # 大小判定
    A = weak_strong_trump.index(A)
    B = weak_strong_trump.index(B)
    # 結果
    if A > B:
        return 'Alice'
    elif A == B:
        return 'Draw'
    elif A < B:
        return 'Bob'

# 実行
result = jubge_winner()
print(result)

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


int main()
{

    int a , b , result = 0 , ab;
    
    cin >> a >> b;
    if( 1 < a && a < b ){
	ab = b % a;
	for( int i = 1; i <= ab; i++ ){
	    if( ab % i == 0 && a % i == 0 )
		result = max(i,result);
	}
    } else if(1 < b && b < a ){
	ab = a % b;
	//	cout << ab << endl;
	for( int i = 1; i <= ab; i++ ){
	    if( ab % i == 0 && b % i == 0 )
		result = max(i,result);
	}
    }else if( a == b ) result = a;
    
    

    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
  int n, m;
  int i, j;

/******************input*****************/

  scanf("\n%d %d",&n, &m);
  int M[n][m];/*matrix*/
  for(i=0; i<n; i++) {
    for(j=0; j<m; j++) {
      scanf("%d", &M[i][j]);
    }
  }
  int V[m];/*vector*/
  for(j=0; j<m; j++) {
    scanf("%d", &V[j]);
  }

/******************output****************/

  int R[n];/*result*/
  for(i=0; i<n; i++) {
    R[i]=0;
    for(j=0; j<m; j++) {
      R[i]=R[i]+M[i][j]*V[j];
    }
    printf("%d\n", R[i]);
  }

  return 0;

}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<assert.h>
#include<sstream>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e18 + 7;
const int N = 1e3 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
//-------------head-------------
ll kpow(ll a, ll b) {
	ll r = 1;
	while (b > 0) {
		if (b & 1)
			r = r * a % MOD;
		a = a * a % MOD, b >>= 1;
	}
	return r;
}
void inc(ll &x, ll y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
}
struct Mat {
	ll a[2][2];
	Mat operator*(const Mat &p) const {
		Mat ret;
		memset(ret.a, 0, sizeof(ret.a));
		rep(i, 0, 2)
			rep(j, 0, 2)
				rep(k, 0, 2)
					inc(ret.a[i][j], a[i][k] * p.a[k][j] % MOD);
		return ret;
	}
	Mat operator^(ll b) {
		Mat ret, x = *this;
		rep(i, 0, 2)
			rep(j, 0, 2)
				ret.a[i][j] = (i == j);
		while (b > 0) {
			if (b & 1)
				ret = ret * x;
			x = x * x, b >>= 1;
		}
		return ret;
	}
} A;
int H, W;
ll K;
char s[N][N];
int solve() {
	if (K == 0)
		return 1;
	int tot, hor, ver, pai;
	tot = hor = ver = pai = 0;
	rep(i, 0, H)
		rep(j, 0, W)
			tot += s[i][j] == '#';
	rep(i, 0, H)
		if (s[i][0] == '#' && s[i][W - 1] == '#')
			++hor;
	rep(j, 0, W)
		if (s[0][j] == '#' && s[H - 1][j] == '#')
			++ver;
	if (hor > 0 && ver > 0)
		return 1;
	if (!hor && !ver)
		return kpow(tot, K - 1);
	if (hor)
		rep(i, 0, H)
			rep(j, 1, W)
				if (s[i][j - 1] == '#' && s[i][j] == '#')
					++pai;
	if (ver)
		rep(j, 0, W)
			rep(i, 1, H)
				if (s[i - 1][j] == '#' && s[i][j] == '#')
					++pai;
	A.a[0][0] = tot, A.a[0][1] = MOD - pai;
	A.a[1][0] = 0, A.a[1][1] = hor + ver;
	A = A ^ (K - 1);
	int ans = (A.a[0][0] + A.a[0][1]) % MOD;
	return ans;
}
int main() {
	scanf("%d%d%lld", &H, &W, &K);
	rep(i, 0, H)
		scanf(" %s", s[i]);
	printf("%d", solve());
	return 0;
}


Measured memory_bytes: 1280
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	
	if((a%3==0)||(b%3==0)||((a+b)%3==0)){
		System.out.println("Possible");
	}else {
		System.out.println("Impossible");
	}
	}
}


Measured memory_bytes: 21972
function Main(input) {
	 const num = input.split(" ");
   const a = parseInt(num[0], 10);
   const b = parseInt(num[1], 10);
   const ans = a * b;
   if (ans % 2 === 0) {
     console.log("Even")
   }
   else{
     console.log("Odd")
   }
}

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


Measured memory_bytes: 16712
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] NK = br.readLine().split(" ");
        int N = Integer.parseInt(NK[0]);
        int K = Integer.parseInt(NK[1]);
        String S = br.readLine();
        
        int happiness = 0;
        for(int i = 0; i < N - 1; i++){
            if( S.charAt(i) == S.charAt(i+1) ) happiness++;
        }
        
        System.out.println(Math.min(happiness += K * 2, N - 1));
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

vector<ll> divisor(ll s){
    vector<ll> a;
    for(ll i = 1; i*i<=s; i++){
        if(s%i==0){
            a.emplace_back(i);
            if(i*i!=s){
                a.emplace_back(s/i);
            }
        }
    }
    return a;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a = divisor(n);
    vector<ll> b = divisor(n-1ll);
    ll ans = b.size()-1ll;
    debug(a);
    debug(b);
    for(auto &x: a){
        if(x==1ll) continue;
        ll t = n;
        while(t%x==0ll){
            t /= x;
        }
        if(t%x==1ll){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ll exp_five = 5;
  if (n % 2 == 0) {
    while (n > exp_five) {
      ans += ((n / 2) / exp_five);
      exp_five *= 5;
    }
  }

  cout << ans << endl;
}

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

int main() {
        const int KM = 4;
        vector<int> A(KM);
        vector<int> B(KM);

        rep(i, KM) {
                cin >> A.at(i);
        }
        rep(i, KM) {
                cin >> B.at(i);
        }
        cout << max(accumulate(A.begin(), A.end(), 0), accumulate(B.begin(), B.end(), 0)) << endl;

        return 0;
}



Measured memory_bytes: 3076
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

roots = [(i,1) for i in range(N+1)] # root, num_islands_in_group

inconveniences = [0]*(M+1)
inconveniences[-1] = N*(N-1)//2 #すべての橋が崩落するとNC2

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return roots[a]
  else:
    roots[a] = find_root(roots[a][0])
  return roots[a]

def reduce_inconvenience_with_unite(a, b, roots=roots):
  root_a, n_a = find_root(a)
  root_b, n_b = find_root(b)
  if root_a == root_b:
    return 0
  else:
    if n_a > n_b:
      roots[root_a] = (root_a, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_a, n_a + n_b)
    else:
      roots[root_a] = (root_b, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_b, n_a + n_b)
    return n_a * n_b

for i, ab in enumerate(AB[:0:-1]): #実は1個めの橋は全く関係ない
  a, b = ab
  inconveniences[M-1-i] = inconveniences[M-i] - reduce_inconvenience_with_unite(a,b)

for inc in inconveniences[1:]:
  print(inc)


Measured memory_bytes: 43740
// 2020-08-23 22:41:51
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s;
  cin >> s;
  int cur = 0;
  rep(i, s.size()) {
    cur += s[i] - '0';
    cur %= 9;
  }
  string ans = "Yes";
  if(cur > 0) ans = "No";
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int v[n],c[n],s=0;
  for(int i=0;i<n;i++)cin >> v[i];
  for(int i=0;i<n;i++)cin >> c[i];
  for(int i=0;i<n;i++){
    if(v[i]>c[i])s+=v[i]-c[i];
  }
  cout << s;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int N,M;
bool onVec[10];
vector<int> swi[10];
vector<int> po(10);

int dfs(int depth){
    if(N==depth) {
        int res = 0;
        REP(j,M){
            int count = 0;
            for(auto i:swi[j]){
                if(onVec[i]) count++;
            }
            if(count % 2 == po[j]) res ++;
            else return 0;
        }
        if(res == M) return 1;
        else return 0;
    }
    int ret = 0;
    onVec[depth]=true;
    ret += dfs(depth+1);
    onVec[depth]=false;
    ret += dfs(depth+1);

    return ret;
}

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

    REP(i,M){
        int k;cin >> k;
        REP(j,k) {
            int s;cin >> s,s--;
            swi[i].push_back(s);
        }
    }
    
    REP(i,M){
        cin >> po[i];
    }

	pl(dfs(0))
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int ans = 0;
		int value = 0;
		for(int i=0; i<3; i++) {
			if(S.charAt(i) == 'R') {
				value++;
				ans = Math.max(ans, value);
			}else {
				value = 0;
			}
		}

		System.out.println(ans);

	}


}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

int N, K;
int pasta[110];

int dp[110][10][10];
const int MOD = 10000;

void solve() {
	minit(dp, 0);
	if (pasta[0] != -1) dp[1][pasta[0]][1] = 1;
	else for_(j,0,3) dp[1][j][1] = 1;
	
	for_(i,1,N) for_(j,0,3) for_(k,1,3) {
		if (pasta[i] == -1) {
			for_(jj,0,3) {
				if (j == jj) {
					dp[i + 1][jj][k + 1] += dp[i][j][k];
					dp[i + 1][jj][k + 1] %= MOD;
				}
				else {
					dp[i + 1][jj][1] += dp[i][j][k];
					dp[i + 1][jj][1] %= MOD;
				}
			}
		} else {
			if (j == pasta[i]) {
				dp[i + 1][j][k + 1] += dp[i][j][k];
				dp[i + 1][j][k + 1] %= MOD;
			}
			else {
				dp[i + 1][pasta[i]][1] += dp[i][j][k];
				dp[i + 1][pasta[i]][1] %= MOD;
			}
		}
	}
	
	int ans = 0;
	for_(j,0,3) for_(k,1,3) {
		ans += dp[N][j][k];
		ans %= MOD;
	}
	
	cout << ans << endl;
}

int main() {
	cin >> N >> K;
	
	minit(pasta, -1);
	for_(i,0,K) {
		int a, b; cin >> a >> b;
		--a; --b;
		pasta[a] = b;
	}
	
	solve();
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>

int main()
{
	int a[5];
	int k;
	for (auto i = 0; i < 5; i++)
	{
		std::cin >> a[i];
	}
	std::cin >> k;

	int min_index = 0;

	for (auto i = 0; i < 5; i++)
	{
		if ((a[min_index] - 1) % 10 > (a[i] - 1) % 10)
		{
			min_index = i;
		}
	}
	int min = 0;

	for (auto i = 0; i < 5; i++)
	{
		if (i == min_index)
		{
			continue;
		}

		if (a[i] % 10 == 0)
		{
			min += a[i];
		}
		else
		{
			min += (a[i] / 10) * 10 + 10;
		}
	}

	min += a[min_index];

	std::cout << min;

}

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

using namespace std;
using ll = long long;

constexpr ll mod = 1000000007;


template<typename T>
constexpr T modpow(T a,int n){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

int main() {
    int k,n;
    cin>>n>>k;
    vector<pair<ll,ll>> a(n);
    int pl=0,mn=0;
    for(int i = 0;i < n;++i) {
        cin>>a[i].second;
        a[i].first=(a[i].second<0 ? -a[i].second : a[i].second);
        if(a[i].second<0)++mn;
        else ++pl;
    }
    sort(a.rbegin(),a.rend());
    ll ans=1LL;

    if((pl==0&&k%2==1)||(k==n&&mn%2==1)) {//ans is minus
        for(int i = 0;i < k;++i) {
            ans *= a[n-1-i].second;
            ans%=mod;
        }
        if(ans<0)ans+=mod;
        cout<<ans<<endl;
        return 0;
    }

    for(int i = 0;i < k;++i) {
        ans *= a[i].second;
        ans%=mod;
    }

    if(ans>=0) {
        cout<<ans<<endl;
        return 0;
    }

    ll tans=1;
    ll ttans=1;

    ll t=1,tt=1;

    for(int i = k-1;i >= 0;--i) {
        if(a[i].second>0) {
            tans*=modpow(a[i].second,mod-2);
            tans%=mod;
            tt*=a[i].first;

            break;
        }
        if(i==0){
            t=0;
            tans=0;
        }
    }
    for(int i = k;i < n;++i) {
        if(a[i].second<0) {
            tans*=a[i].second;
            tans%=mod;
            t*=a[i].first;
            break;
        }
        if(i==n-1){
            t=0;
            tans=0;
        }
    }

    for(int i = k-1;i >= 0;--i) {
        if(a[i].second<0) {
            ttans*=modpow(a[i].first,mod-2);
            ttans*=-1;
            ttans%=mod;
            t*=a[i].first;
            break;
        }
        if(i==0){
            tt=0;
            ttans=0;
        }
    }

    for(int i = k;i < n;++i) {
        if(a[i].second>0) {
            ttans*=a[i].second;
            ttans%=mod;
            tt*=a[i].second;
            break;
        }
        if(i==n-1){
            tt=0;
            ttans=0;
        }
    }
    if(t<tt){
        cout<<(ans * ttans)%mod<<endl;
    }
    else {
        cout<<(ans * tans)%mod<<endl;
    }

    return 0;
}


Measured memory_bytes: 6332
sub i{$t=<STDIN>;split/ /,$t;}@c=i;for($j=0;$j<$c[2];$j++){@d=i;if($d[1]<=$d[0]){${$s[$d[1]]}[@{$s[$d[1]]}]=$d[0];}}$e=$c[0]+1;$f=1;for($j=1;$j<=$c[1];$j++){foreach$g(sort{$a<=>$b}@{$s[$j]}){if($f==$g){$f++;}if($f<$g&&$e>$g){$e=$g;}}$f++;}$e--;print$e;

Measured memory_bytes: 28336
while(n,p=gets.split.map(&:to_i))!=[0,0]
	a=Array.new(n,0)
	i=0
	c=p
	while (a[i]!=p)
		c==0 ? (c+=a[i];a[i]=0) : (a[i]+=1;c-=1) 
		i=(i+1)%n
	end
	puts i
end

Measured memory_bytes: 6100
// [AT3848 Postal Code] https://www.luogu.org/problemnew/show/AT3848
#include <iostream>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int a, b;
    string s;

    cin >> a >> b;
    cin >> s;

    int slen = s.length();
    for (int i = 0; i < a; i++)
    {
        if (s[i] < '0' || s[i] > '9')
        {
            cout << "No" << endl;
            return 0;
        }
    }

    if (s[a] != '-')
    {
        cout << "No" << endl;
        return 0;
    }

    for (int i = a+1; i < slen; i++)
    {
        if (s[i] < '0' || s[i] > '9')
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        int a = int.Parse(s[0].ToString());
        int b = int.Parse(s[1].ToString());
        int c = int.Parse(s[2].ToString());
        int d = int.Parse(s[3].ToString());
        int[] nums = new int[] { a, b, c, d };

        int n = 3; // 対象数
        for (int i = 0; i < Math.Pow(2, n); i++)
        {
            int answer = a;
            string answerStr = "" + a;
            for (int j = 0; j < n; j++)
            {
                if ((1 & (i >> j)) == 1)
                {
                    // bitが立っている際のチェック処理
                    answer += nums[j + 1];
                    answerStr += "+" + nums[j + 1];
                }
                else
                {
                    answer -= nums[j + 1];
                    answerStr += "-" + nums[j + 1];
                }
            }
            if (answer == 7)
            {
                answerStr += "=7";
                Console.WriteLine(answerStr);
                return;
            }
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11220
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	if (s[0] != 'A') {
		cout << "WA\n";
		return 0;
	}
	int p = 0;
	map<char, int>m;
	int cnt = 0;
	for (auto i : s) {
		if (i == 'C')p = cnt;
		m[i]++;
		cnt++;
	}
	N = s.size();
	if (p <= 1 || p == N - 1) {
		cout << "WA\n";
		return 0;
	}
	if (m['A'] != 1 || m['C'] != 1) {
		cout << "WA\n";
		return 0;
	}
	for (auto i : m) {
		if (i.first >= 'A'&&i.first <= 'Z'&&i.first != 'A'&&i.first != 'C') {
			cout << "WA\n";
			return 0;
		}
	}
	cout << "AC\n";
	return 0;
}

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

int main(){
	long long int n, a, s;
	double t;
	cin >> n;
	t = sqrt((double)n);
	a = (int)t;
	for(int i = 1; i <= a; i++){
		if(n % i == 0){
			s = n / i;
		}
	}
	int p = 0;
	while(s != 0){
		s /= 10;
		p++;
	}
	cout << p << endl;
}

Measured memory_bytes: 256
<>;
for(`factor`){
	$x=$y=1;
	s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$y*=$&**(-$a%3)/ge;
	++$h{$x};
	$t{$x}=$y
}
$%=!!$h{1};
$h{1}=0;
for(keys%h){
	$%+=$h{$h{$_}>$h{$t{$_}}?$_:$t{$_}};
	$h{$_}=$h{$t{$_}}=0
}
print$%


Measured memory_bytes: 53460
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

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

const int md = 1e9 + 7;
const ll INF = 1e18;
const int N = 1e6 + 12; //check the limits, dummy

ll fact[N];

inline ll inv (ll a) {
    a %= md;
    if (a < 0) {
        a += md;
    }
    ll b = md, u = 0, v = 1;
    while (a) {
        ll t = b / a;
        b -= t * a;
        swap (a, b);
        u -= t * v;
        swap (u, v);
    }
    assert (b == 1);
    if (u < 0) {
        u += md;
    }
    return u;
}

int main() {

    ios_base::sync_with_stdio (0);
    cin.tie (0);

    fact[0] = 1;
    FOR (i, 1, N) fact[i] = fact[i - 1] * i % md;

    ll x, y;
    cin >> x >> y;

    ll tot = x + y;

    // n + 2m = x && 2n + m = y
    // (x + y) / 3 - x = n + m - n - 2m = m
    if (tot % 3) {
        cout << "0\n";
        return 0;
    }
    tot /= 3;
    ll m = x - tot;
    if (m == 0) {
        cout << 1 << '\n';
        return 0;
    }
    if (m < 0) {
        cout << 0 << '\n';
        return 0;
    }

    if (tot < m) {
        cout << 0 << '\n';
        return 0;
    }

    ll ans = fact[tot];
    ans = ans * inv (fact[m]) % md;
    ans = ans * inv (fact[tot - m]) % md;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

int main(void)
{
    int i, n, q, a[100000], b[100000], c[100000], d[100001] ={};
    long long int ans = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", a + i);
        ans += a[i];
        d[a[i]]++;
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++)
        scanf("%d%d", b + i, c + i);
    for (i = 0; i < q; i++)
    {
        ans += d[b[i]] * (c[i] - b[i]);
        printf("%lld\n", ans);
        d[c[i]] += d[b[i]];
        d[b[i]] = 0;
    }
}


Measured memory_bytes: 3284
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

s=input()
n=len(s)-([2,1][len(s)%2])
s=s[:n]
while 1:
    if (s[(n//2):n]==s[:(n//2)]):
        print(n)
        exit()
    n-=2
    s=s[:n]

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

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

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    string s, t; cin >> s >> t;
    int n = sz(s), m = sz(t);
    vvi dp(n + 1, vi(m + 1, 0));
    vector<vpi> last(n + 1, vpi(m + 1, {-1, -1}));
    vector<vb> used(n + 1, vb(m + 1, false));
    // dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] + 1)
    F0R (i, n) {
        F0R (j, m) {
            if (s[i] == t[j]) {
                if (dp[i][j + 1] > dp[i][j] + 1) {
                    last[i + 1][j + 1] = {i, j + 1};
                    dp[i + 1][j + 1] = dp[i][j + 1];
                } else {
                    last[i + 1][j + 1] = {i, j};
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                    used[i + 1][j + 1] = true;
                }
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
                if (dp[i][j + 1] > dp[i + 1][j]) {
                    last[i + 1][j + 1] = {i, j + 1};
                    dp[i + 1][j + 1] = dp[i][j + 1];
                } else {
                    last[i + 1][j + 1] = {i + 1, j};
                    dp[i + 1][j + 1] = dp[i + 1][j];
                }
            }
        }
    }
    pii cur = {n, m};
    string ans = "";
    while (cur.F > 0 && cur.S > 0) {
        if (used[cur.F][cur.S]) {
            ans += s[cur.F - 1];
        }
        cur = last[cur.F][cur.S];
    }
    reverse(all(ans));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 107264
s = list(input())
i = 0
list1 = []
while i < len(s) - 2:
  l = [int(s[i]), int(s[i + 1]), int(s[i + 2])]
  num = 100 * l[0] + 10 * l[1] + l[2]
  list1.append(abs(753 - num))
  i += 1
print(min(list1))

Measured memory_bytes: 3060
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int t = sc.nextInt();
		double a = sc.nextInt();
		double min = 1000000;
		int ans = 0;

		int h[] = new int[n];

		for (int i = 0;i<n ;i++ ) {
			h[i] = sc.nextInt();
		}

		for (int i = 0;i<n ;i++ ) {
			double data = t-h[i]*0.006;
			min = Math.min(min,Math.abs(a-data));
			if (min==Math.abs(a-data)) {
				 ans = i+1;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
  int a, b, k;

  cin >> a >> b >> k;

  for (int i = a; i <= b; i++){
    if (i - a < k || b - i < k){
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256