akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    static int count;//BÂ\È^C
    static int w;//xûüÌ·³
    static int h;//yûüÌ·³

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

	w = sc.nextInt();//x
	h = sc.nextInt();//y

	while(w!=0 && h!=0){
	    count = 0;
	    char[][] tile = new char[h][w];//^Cð»ÌÜÜi[
	    int[][] pass = new int[h][w];//Êßµ½ÚóB0(ÊÁÄÈ¢)Æ1(ÊÁ½)ÅL^
	    int posX = 0;//»ÝnÌxÀW
	    int posY = 0;//»ÝnÌyÀW
	    //^Cú»
	    for(int i=0; i<h; i++){
		String line = sc.next();//êsÇÝñÅ©ç
		for(int j=0; j<w; j++){
		    tile[i][j] = line.charAt(j);
		    if(tile[i][j]=='@'){//»ÝÊuðL^
			posX = j;
			posY = i;
		    }
		}
	    }
	    solve(tile,pass,posX,posY);
	    System.out.println(count);
	    
	    w = sc.nextInt();
	    h = sc.nextInt();
	}
    }

    public static void solve(char[][] tile, int[][] pass,int posX, int posY){
	if(pass[posY][posX]==0){//Êßµ½Úó
	    pass[posY][posX] = 1;
	    count++;
	}else return;//ÊßµÄ½çreturn

	if(posY-1>=0 && tile[posY-1][posX]=='.'){//ãûü
	    solve(tile,pass,posX,posY-1);
	}
	if(posX+1<=w-1 && tile[posY][posX+1]=='.'){//Eûü
	    solve(tile,pass,posX+1,posY);
	}
	if(posY+1<=h-1 && tile[posY+1][posX]=='.'){//ºûü
	    solve(tile,pass,posX,posY+1);
	}
	if(posX-1>=0 && tile[posY][posX-1]=='.'){//¶ûü
	    solve(tile,pass,posX-1, posY);
	}

	return;
    }
}

Measured memory_bytes: 12000
n = int(input())
a = list(map(int, input().split()))
c = 0
m = 10**10
flag = 0
ans = 0
for i in a:
    if i == 0:
        flag = 1
    if i < 0:
        c += 1
    ans += abs(i)
    m = min(m,abs(i))
if c%2 == 0:
    flag = 1
if flag:
    print(ans)
else:
    print(ans-(2*m))



Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
int main() 
{
  int n,k;
  cin>>n>>k;
  set<int> ans;
  for(int i=0;i<k;i++)
  {
  	  int kk;
  	  cin>>kk;
  	  for(int ii=0;ii<kk;ii++)
  	  {
  	  	int temp;
  	  	cin>>temp;
  	  	ans.insert(temp);
 	}
  }
  cout<<n-ans.size()<<"\n";
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    static final String[] VERDICTS = { "AC", "WA", "TLE", "RE" };

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

        int N = sc.nextInt();
        String[] S = new String[N];
        for (int i = 0; i < S.length; ++i) {
            S[i] = sc.next();
        }
        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String[] S) {
        int[] counts = new int[VERDICTS.length];
        for (String Si : S) {
            int index = IntStream.range(0, VERDICTS.length).filter(i -> VERDICTS[i].equals(Si)).findAny().getAsInt();
            ++counts[index];
        }

        return IntStream.range(0, VERDICTS.length).mapToObj(i -> String.format("%s x %d", VERDICTS[i], counts[i]))
                .collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 66492
n, m = map(int, input().split())
l = [[int(i) for i in input().split()] for _ in [0]*n]
ans = 0

def  getmm(k):
  f = lambda x: (x[0] if k & 1 else -x[0]) + (x[1] if k & 2 else -x[1]) + (x[2] if k & 4 else -x[2])
  al = [f(e) for e in l]
  al.sort(reverse=True)
  return sum(al[:m])

for i in range(8):
  ans = max(ans, getmm(i))
print(ans)

Measured memory_bytes: 3300
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long UN = sc.nextLong();
		sc.close();
		sc = null;
		long x;
		long s = UN / 4 + 1;
		long s0,s1;
		long h=0,n=0,w=0;
		LABEL:for(h=s;h<=3500;h++) {
			for(n=h;n<=3500;n++) {
				x=h*n;
				s0=UN*x;
				s1=4*x-UN*(n+h);
				if(s1<=0)continue;
				if(s0%s1==0) {
					w=s0/s1;
					break LABEL;
				}
			}
		}
		System.out.println(h + " " + n + " " + w);
	}
}


Measured memory_bytes: 23764
/*************************************************************************
	> File Name: m.cpp
	> Author: LiuGeXian
	> Mail: 1019630230@qq.com 
	> Created Time: 2020/5/11 7:08:09
 ************************************************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll n;
map<ll, ll> m;
ll Solve(ll x){
	if (m[x]) return m[x] % MOD;
	return m[x] = (Solve((x-1)/2) + Solve(x / 2) + Solve((x-2)/2)) % MOD;
}
int main(){
	scanf("%lld", &n);
	m[0] = 1;
	m[1] = 2;
	cout << Solve(n) << endl;
	return 0;
}


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

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, m, val;
	
	cin >> n >> m;
	
	int k;
	
	vector<int> v[m+5];
	
	for(int i = 0; i < m; i++){
		cin >> k;
		
		for(int j = 0; j < k; j++){
			cin >> val;
			v[i].push_back(val);
		}
	}
	
	
	int p[m+5];
	for(int i = 0;  i < m; i++) cin >> p[i];
	
	int mask, cnt = 0, cnt2, cnt3;
	
	map<int, int> mp;
	
	for(int i = 0; i < (1 << n); i++){
		
		int l = n, iii = i;
		
		for(int j = 0; j < n; j++){
			mask = 1 << j;
			mask = mask & iii;
			
			if(mask != 0) mp[l] = 1;
			else mp[l] = 0;
			
			l--;
		}
		
		cnt3 = 0;
		
		for(int ii = 0; ii < m; ii++){
			cnt2 = 0;
			for(int j = 0; j < (int)v[ii].size(); j++){
				if(mp[v[ii][j]]) cnt2++;
			}
			
			if((cnt2%2) == p[ii]) cnt3++;
		}
		
		if(cnt3 == m) cnt++;
	}
	
	cout << cnt << "\n";
	
	return 0;
}


Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, m;
  cin >> n >> m;
  map<ll, ll> done, wp;
  ll ac = 0, wa = 0;
  for(ll i = 1; i <= m; i++) {
  	ll x;
  	string p;
  	cin >> x >> p;
  	if(p == "AC") {
  		if(done[x]) continue;
  		else {
  			ac++;
  			wa+= wp[x];
  			done[x] = true;
  		}
  	} else {
  		if(done[x]) continue;
  		wp[x]++;
  	}
  }
  cout << ac << " " << wa << endl;
  return 0;
} //good night.

Measured memory_bytes: 12800
n,*a=map(int,open(0).read().split())
d=[0]*-~n
for h,a in zip(a,a[n:]):
 i,s=h,0
 while i:s=max(s,d[i]);i-=i&-i
 while h<=n:d[h]=max(d[h],s+a);h+=h&-h
print(max(d))

Measured memory_bytes: 125048
fun main(args: Array<String>) {
    val (n, k, sum) = readLine()!!.split(" ").map { it.toInt() }
    if (sum < 1000000000) {
        val out = IntArray(n) { sum + 1 }
        repeat(k) { out[it] = sum }
        println(out.joinToString(" "))
    } else {
        val out = IntArray(n) { 1 }
        repeat(k) { out[it] = sum }
        println(out.joinToString(" "))
    }
}

Measured memory_bytes: 43612
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  string people(n, ' ');
  scanf(" %s", &people[0]);
  int result = count(people.begin() + 1, people.end(), 'E');
  int best_result = result;
  for (int i = 1; i < n; ++i) {
    if (people[i] == 'E') --result;
    if (people[i - 1] == 'W') ++result;
    best_result = min(best_result, result);
  }
  printf("%d\n", best_result);
  return 0;
}


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

int main(){
  int n; cin >> n;
  string s, t; cin >> s >> t;
  
  string res = "";
  for(int i=0; i<n; ++i){
    res += s[i];
    res += t[i];
  }
  
  cout << res << endl;
  return 0;
}

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

int main()
{
    int in_d, in_t, in_s;
    cin >> in_d >> in_t >> in_s;
    float speed = (float)in_d / (float)in_s;
    if (speed <= (float)in_t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
#define N (int)1e6+10
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
void fast() {

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

#ifdef ONLINE_JUDGE
	//	freopen("palindrome.in", "r", stdin);

	//freopen("palindrome.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("9000000.txt", "r", stdin);

	//freopen("ConsoleApplication1.zip", "w", stdout);
#endif
}
// create Node
class node
{
public:
	 int data;
	node* next;
	node()
	{
		data = 0;
		next = NULL;
	}
};

class LinkedList
{
private:
	node* Head;
public:
	LinkedList()
	{
		Head = NULL;
	}

	void InsertItem(int d)
	{
		node* n=new node; // create new node
		n->data = d;
		if (Head == NULL)
		{
			Head = n;
			n->next = NULL;
		}

		else
		{
			node* t = Head;
			while (t->next != NULL)
				t = t->next;
			t->next = n;
			n->next = NULL;
		}
	}

	void DeleteItem(int d)
	{
		node* c = Head;
		node* p=NULL;
		if (c != NULL && c->data == d)
		{
			Head = Head->next;
			return;
		}
		while (c != NULL)
		{
			if (c->data == d)
				break;
			p = c;
			c = c->next;
		}
		if (c != NULL)
		{
			p->next = c->next;
		}
		else
		{
			cout << "Not Found" << endl;
		}

	}

	void PrintItem()
	{
		node* t = Head;
		cout << "Items:" << endl;
		while (t != NULL)
		{
			cout << t->data << "  ";
			t = t->next;
		}
		cout << endl;
	}

};

int main()
{
	Mohammed_Atef_Hassan
		/*	LinkedList s;
		s.InsertItem(1);
		s.InsertItem(2);
		s.PrintItem();
		s.DeleteItem(1);
		s.PrintItem();*/
		pair<ll,ll>arr[51];
	arr[0] = { 1,1 };
	for (int i = 1; i <= 50; i++)
	{
		arr[i] = { arr[i - 1].first*2 + 3,arr[i - 1].second*2 + 1 };
	}
	int n; ll k; ll cnt = 0;
	cin >> n >> k;
	while (n>=0)
	{
		int i = n;
		while (k < arr[i].first)
		{
			k--; i--;
		}
		if (i < 0)break;
		cnt += arr[i].second;
		k -= arr[i].first;
		if (k <= 0)break;
		if (k > 0)
		{
			k--; cnt++;
		}
		n = i;
	}
	cout << cnt << finl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll gcd(ll x, ll y)
{
    ll temp;
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  ll n; cin >> n;
  ll ref = 1;
  ll breakwall = 0;
  FOR(i,0,n-1){
    ll a; cin >> a;
    if(a==ref) ++ref;
    else ++breakwall;
  }

  if(breakwall==n) cout << -1 << endl;
  else cout << breakwall << endl;
}

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



void solve(int N, std::string S) 
{
  int solution = 0;
  char previous_color = S.front();
  for (int i = 0; i < N; i++)
  {
    char current_color = S[i];
    if(current_color != previous_color)
    {
      solution++;
    }
    previous_color = current_color; 
  }
  std::cout << solution+1 << std::endl;
}

int main(void) 
{
  int N;
  std::string S;
  std::cin >> N;
  std::cin >> S;
  solve(N,S);
  return 0;
}


Measured memory_bytes: 512
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  i64 price = 1000;
  i64 stock = 0;
  rep(i, n) {
    if (i == n - 1) {
      price += stock * a[i];
      continue;
    }
    if (a[i] > a[i + 1]) {
      price += stock * a[i];
      stock = 0;
    } else if (a[i] < a[i + 1]) {
      i64 c = price / a[i];
      price -= c * a[i];
      stock += c;
    }
  }
  cout << price << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 3656
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Queue
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)


  val V, M = in.next().toInt
  val E = V-1 + M

  val graph = Array.fill[List[Int]](V+1)(Nil) // 隣接リスト
  val indegree = new Array[Int](V+1) // 入次数

  // input
  for (_ <- 1 to E) {
    val a, b = in.next().toInt
    graph(a) = b :: graph(a)
    indegree(b) += 1
  }

  var deg0 = new scala.collection.mutable.Stack[Int]
  for (i <- 1 to V) {
    if(indegree(i) == 0)
      deg0.push(i)
  }

  var res = List[Int]()
  while(!deg0.isEmpty) {
    val node = deg0.pop()
    res = node :: res
    for (e <- graph(node)) {
      indegree(e) -= 1 // 隣接する頂点の入次数をマイナス1
      if (indegree(e) == 0) // これによって入次数が0になればstに追加
        deg0.push(e)
    }
  }

  res = res.reverse
  

  //
  val root = res.head
  val ans = new Array[Int](V+1)

  for(node <- res) {
    for(e <- graph(node)) {
      ans(e) = node
    }
  }

  for (i <- 1 to V) {
    if(i == root)
      println(0)
    else
      println(ans(i))
  }
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 61764
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion



int main(void)
{
	ll      a,b,n;

	ll_cin(a);	ll_cin(b); ll_cin(n);

	if (n >= b) n = b - 1;

	ll_cout((ll)floor(a * n / b) - a * (ll)floor(n / b));
		
	return 0;
}

//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 1736
S = list(input())
T = list(input())
result = 0
n = 0
N = len(S)

while result == 0 and n < N:
    if S == T:
        result = 1
    else:
        S = S[1:N] + [S[0]]
        n += 1
        
if result == 0:
    print('No')
else:
    print('Yes')

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


int main() {
    int N,K;
    cin >> N >> K;
    int ans = 0;
    while(N){
        N/=K;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

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

int main(void){
  int N, K; cin >> N >> K;
  vector<int> h(N);
  for(auto& _h: h) cin >> _h;
  sort(h.begin(), h.end());

  int ans = 1000000010;
  for(int l = 0; l + K - 1 < N; l++){
    int r = l + K - 1;
    ans = min(ans, h[r] - h[l]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
 string s;
 string t;
cin>>s;
cin>>t;
int k=0;
if(t.length()==s.length()+1){
  for(unsigned i=0; i<s.length(); ++i){
    if(s.at(i)==t.at(i))
        k++;
    }

  int l=s.length();
  if(k==l){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
else{
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 3560
//
//  main.cpp
//  0003
//
//  Created by 竹内 文登 on 13/07/14.
//  Copyright (c) 2013年 竹内 文登. All rights reserved.
//

#include <iostream>
using namespace std;
int main()
{
    int M;
    int a,b,c;
    
    cin >> M;
    
    while(cin >> a >> b >> c){
        if(a*a == b*b + c*c)
            cout << "YES" <<endl;
        else if(a*a + b*b == c*c)
            cout << "YES" <<endl;
        else if(a*a + c*c ==b*b)
            cout << "YES" <<endl;
        else
            cout << "NO" << endl;
    }
    
    
    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	string s, t; cin >> s >> t;


	vector < set <int> > m(26);

	for(int i = 0; i < s.size(); i++){
		m[s[i] - 'a'].insert(i);
	}

	int current = -1, counter = 0;

	for(char c : t){

		if(m[c - 'a'].empty()){
			cout << -1 << endl;
			return 0;
		}

		auto it = m[c - 'a'].upper_bound(current);

		if(it == m[c - 'a'].end()){
			counter++;
			current = *m[c - 'a'].begin();
		}else{
			current = *it;
		}
	}

	cout << counter * s.size() + current + 1 << endl;

	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x, y;
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if (x==0 && y==0) break;
            if (x<y) {
                System.out.println(x+" "+y);
            } else {
                System.out.println(y+" "+x);
            }
        }
    }
}


Measured memory_bytes: 35880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int D; cin >> D;
    vector<ll> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(i, D)rep(j, 26) cin >> s[i][j];
    vector<ll> t(D);
    rep(i, D) cin >> t[i];
    ll ans = 0;
    vector<ll> last(26);
    for (int d = 1; d <= D; d++) {
        for (int i = 1; i <= 26; i++) {
            if (t[d-1] == i) {
                ans += s[d-1][i-1];
                last[i-1] = d;
            }
            else {
                ans -= c[i-1]*(d-last[i-1]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[100000], basis[60];

int main() {
    init();
    ll N;
    cin>>N;
    ll a = 0;
    rep(i, N) cin >> A[i], a ^= A[i];

    rep(i, N) A[i] &= ~a;

    rep(i,N){
        repr(j,60){
            if(A[i]>>j & 1){
                if(basis[j])
                    A[i] ^= basis[j];
                else{
                    basis[j] = A[i];
                    break;
                }
            }
        }
    }

    repr(i,60){
        repr(j,i){
            if (basis[i] >> j & 1) basis[i] ^= basis[j];
        }
    }

    ll ans = 0;
    repr(i, 60) ans ^= basis[i] << 1;

    cout << ans + a << endl;
}   

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 405;
const ll LINF = 1e18 + 5;
int h, w;
char s[N][N];
int f[N*N];
constexpr int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int find(int x)
{
	if(x==f[x]) return x;
	return f[x] = find(f[x]);
}
void merge(int x, int y)
{
	int fx = find(x), fy = find(y);
	if(fx!=fy) f[fx] = fy;
}
pii rt[N*N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h >> w;
 	for(int i=1; i<=h; i++)
 		cin >> (s[i]+1);
 	for(int i=1; i<=h; i++)
 		for(int j=1; j<=w; j++)
 			f[(i-1)*w+j] = (i-1)*w+j;
 	for(int i=1; i<=h; i++)
 	{
 		for(int j=1; j<=w; j++)
 		{
 			for(int k=0; k<4; k++)
			{
				int ti = i + dir[k][0], tj = j + dir[k][1];
				if(ti>=1 && ti<=h && tj>=1 && tj<=w && s[ti][tj]!=s[i][j])
					merge((i-1)*w+j, (ti-1)*w+tj);
			}
		}
	}
	for(int i=1; i<=h; i++)
		for(int j=1; j<=w; j++)
		{
			int ff = find((i-1)*w+j);
			if(s[i][j]=='.') rt[ff].first++;
			else rt[ff].second++;
		}
	ll ans = 0;
	for(int i=1; i<=h*w; i++) ans += 1ll*rt[i].first*rt[i].second;
	cout << ans;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 55;
vector<int> graph[N];
vector<pair<int, int> > edges;
bool visited[N];
int n, m;

void dfs(int node, int u, int v, int p = 0) {
    if(visited[node]) {
        return;
    }
    visited[node] = true;
    for(nnode : graph[node]) {
        if(nnode == p || nnode == u && node == v || nnode == v && node == u) continue;
        dfs(nnode, u, v, node);
    }
}

bool isc(int u, int v) {
    fill(visited + 1, visited + n + 1, false);
    dfs(1, u, v);
    for(int i = 1; i <= n; i++) {
        if(!visited[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        edges.push_back(make_pair(u, v));
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int ans = 0;
    for(e : edges) {
        if(isc(e.first, e.second)) {
            ans++;
        }
    }
    ans = m - ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import fractions
from functools import reduce

N,X = map(int,input().split())

toshiList = list(map(int,input().split()))

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(fractions.gcd,absList)
    
print(ans)

Measured memory_bytes: 16280
//"header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

int gcd(int a,int b){ return b ? gcd(b,a % b) : a; }
int lcm(int a,int b){ return a / gcd(a,b) * b; }

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}
int N,W;
vector<int> v,w;
vector<vector<int> > mem;

int dp(int i,int j){
	if(i > N) return 0;
	if(mem[i][j] != -1) return mem[i][j];
	if(j + w[i] > W) return mem[i][j] = dp(i + 1,j);
	return mem[i][j] = max(dp(i + 1,j + w[i]) + v[i],dp(i + 1,j));
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> W;
	v.resize(N+1);
	w.resize(N+1);	
	mem.resize(N+1,vector<int>(W+1,-1));
	reps(i,N){
		cin >> w[i] >> v[i];
	}
	cout << dp(1,0) << '\n';	
	return 0;	
}







































Measured memory_bytes: 80256
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<queue>

using namespace std;

typedef pair<int, int> Pi;

#define fr first
#define sc second

int W, H;
Pi Rp, Lp;
string roomL[64], roomR[64];
bool used[51][51][51][51];

bool bfs(Pi R, Pi L)
{
  Pi Crp, Clp;
  queue<Pi> queR, queL;
  int dx[] = {-1, 0, 0, 1},
      dy[] = {0, -1, 1, 0};

  memset(used, false, sizeof(used));

  used[L.fr][L.sc][R.fr][R.sc] = true;
  queR.push(R); queL.push(L);
  while(queR.size()){
    Crp = queR.front(); queR.pop();
    Clp = queL.front(); queL.pop();

    if(Crp == Rp && Clp == Lp) return true;
    if(Crp == Rp && Clp != Lp || Crp != Rp && Clp == Lp) continue;

    for(int i = 0;i < 4; i++){
      int nlx = Clp.fr + dx[i], nly = Clp.sc + dy[i],
          nrx = Crp.fr - dx[i], nry = Crp.sc + dy[i];
      if(nlx < 0 || nlx >= W || nly < 0 || nly >= H)
        nlx = Clp.fr, nly = Clp.sc;
      if(nrx < 0 || nrx >= W || nry < 0 || nry >= H)
        nrx = Crp.fr, nry = Crp.sc;
      if(roomL[nly][nlx] == '#')
        nlx = Clp.fr, nly = Clp.sc;
      if(roomR[nry][nrx] == '#')
        nrx = Crp.fr, nry = Crp.sc;
      if(!used[nlx][nly][nrx][nry]){
        used[nlx][nly][nrx][nry] = true;
        queR.push(make_pair(nrx, nry));
        queL.push(make_pair(nlx, nly));
      }
    }
  }

  return false;
}

int main(void)
{
  Pi Crp, Clp;

  while(cin >> W >> H, W || H){
    for(int i = 0;i < H; i++){
      cin >> roomL[i] >> roomR[i];
      for(int j = 0;j < W; j++){
        if(roomL[i][j] == 'L')
          Clp = make_pair(j, i);
        if(roomR[i][j] == 'R')
          Crp = make_pair(j, i);
        if(roomL[i][j] == '%')
          Lp = make_pair(j, i);
        if(roomR[i][j] == '%')
          Rp = make_pair(j, i);
      }
    }
    cout << (bfs(Crp, Clp)? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 8764
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll A, N, X;
  string S;

  cin >> S;

  if (S == "ABC") {
    cout << "ARC" << endl;
  } else
    cout << "ABC" << endl;

  return 0;
}

Measured memory_bytes: 3608
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [usize;n],
    }

    a.sort();
    a.push(0);
    // let mut cnt: Vec<(usize,usize)> = Vec::new();
    let mut cnt = 0;
    let mut ans = 0;
    let mut now = a[0];
    let mut next = a[1];
    debug!(a);
    for i in 0..n {
        now = a[i];
        next = a[i+1];
        cnt += 1;
        if now!=next {
            if now <= cnt {
                ans += cnt - now;
            } else {
                ans += cnt;
            }
            cnt = 0;
        }
        debug!(ans);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4472
#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>;

const int N = 100005;
const ll INF = 2e18;

vector<P> G[N];

int main() {
  int n;
  cin >> n;
  rep(i, n-1) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }

  int q, k;
  cin >> q >> k;
  --k;
  vector<ll> d(n, INF);
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
  d[k] = 0;
  que.push(make_pair(0, k));
  while (que.size()) {
    int pos = que.top().second;
    que.pop();
    rep(i, G[pos].size()) {
      P p = G[pos][i];
      int to = p.first;
      if (d[pos] + p.second >= d[to]) continue;
      d[to] = d[pos] + p.second;
      que.push(make_pair(d[to], to)); 
    }
  }

  rep(i, q) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    ll ans = d[x] + d[y];
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

#define K 600001

int n, k, a[K];

int diff[K];

int main() {
	scanf("%d%d", &n, &k);
	FOE(i, 1, n) scanf("%d", &a[i]);
	
	FOE(ty, 1, k) {
		FOE(i, 0, n) diff[i] = 0;
		FOE(i, 1, n) {
			int v1 = max(0, i - a[i]);
			diff[v1]++;
			int v2 = min(n + 1, i + a[i] + 1);
			diff[v2]--;
		}
		
		int u = 0;
		
		FOE(i, 0, n) {
			u += diff[i];
			a[i] = u;
		}
		
		int ok = 1;
		FOE(i, 1, n) {
			if (a[i] != n) ok = 0;
		
		}
		
		if (ok) break;
	}
	
	FOE(i, 1, n) printf("%d%c", a[i], (i == n ? '\n' : ' '));
}

Measured memory_bytes: 5384
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int L[210000], R[210000];

int main(){
	int n, m;
	cin >> n >> m;
	vector<P> v;
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		v.push_back(P(x, y));
	}
	sort(v.begin(), v.end());
	for(int i = 1; i <= n; i++){
		L[i] = R[i] = i;
	}
	for(P p : v){
		int y = p.second;
		R[y] = max(R[y], R[y + 1]);
		L[y + 1] = min(L[y + 1], L[y]);
	}
	for(int i = 1; i < n; i++){
		cout << R[i] - L[i] + 1 << " ";
	}
	cout << R[n] - L[n] + 1 << endl;
	return 0;
}



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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[100010];
int init;
int freq[35];
int dp[35][2];
const int INF = 1 << 29;

int rec(int pos, int pa){
    if(pos < 0){
        return 0;
    }
    if(dp[pos][pa] >= 0) return dp[pos][pa];
    int res = INF;
    if(freq[pos] == 0){
        int cbit = ((init >> pos) & 1) ^ pa;
        if(cbit == 0){
            res = min(res, rec(pos - 1, pa));
        }
    }
    else if((freq[pos] % 2) == 1){
        {
            int cbit = ((init >> pos) & 1) ^ pa;
            cbit ^= 1;
            if(cbit == 0)
                res = min(res, rec(pos - 1, pa));
        }
        {
            int cbit = ((init >> pos) & 1) ^ pa;
            if(cbit == 0)
                res = min(res, rec(pos - 1, pa ^ 1) + 1);
        }
    }
    else{
        {
            int cbit = ((init >> pos) & 1) ^ pa;
            cbit ^= 1;
            if(cbit == 0)
                res = min(res, rec(pos - 1, pa ^ 1) + 1);
        }
        {
            int cbit = ((init >> pos) & 1) ^ pa;
            if(cbit == 0){
                res = min(res, rec(pos - 1, pa));
            }
        }
    }
    return dp[pos][pa] = res;
}

int main(){

    fastStream();
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++){
        for(int j = 0 ;; j++){
            if((A[i] >> j) & 1){
                init ^= ((A[i] >> (j + 1)) << (j + 1));
                freq[j]++;
                break;
            }
        }
    }
    memset(dp, -1, sizeof(dp));

    int ans = rec(30, 0);
    if(ans == INF){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


int YYMM(string s){
  int a = stoi(s.substr(0, 2));
  int b = stoi(s.substr(2, 2));
  return 1<=b && b <= 12;
}

int MMYY(string s){
  int a = stoi(s.substr(0, 2));
  int b = stoi(s.substr(2, 2));
  return 1<=a && a <= 12;
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;

  int a = YYMM(s);
  int b = MMYY(s);

  if(a && b) cout<<"AMBIGUOUS"<<endl;
  else if(a) cout<<"YYMM"<<endl;
  else if(b) cout<<"MMYY"<<endl;
  else cout<<"NA"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    vector<int> r(n);
    int sum=0;
    for (int i=0; i<n; i++) {
        cin>>l[i]>>r[i];
        sum += r[i]-l[i]+1;
    }
    cout<<sum<<endl;
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int>l(n);
	for(auto&i:l)cin>>i;
	sort(l.begin(),l.end(),[](auto a,auto b){return a>b;});
	int ans=0;
	for(int i=0;i<k;++i){
		ans+=l.at(i);
	}
	cout<<ans<<"\n"s;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int main()
{
  int n, k;
  cin >> n >> k;

  if((n+1) / 2 < k) cout << "NO" << endl;
  else cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;



int main(){
  int a;
  cin >> a;
  int b;
  cin >> b;

  if ((1 <= a) and (a <= 9) and (1 <= b) and (b <= 9)) {
    cout << (a * b) << endl;
  }
  else{
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int n = s.size();
   bool ok = true;
   rep(i, 0, n) {
      int j = n - 1 - i;
      if (i < j && s[i] != s[j]) {
         ok = false;
      }
   }
   rep(i, 0, n) {
      int j = (n - 1) / 2 - 1 - i;
      if (i < j && s[i] != s[j]) ok = false;
   }
   int cnt = 0;
   rep(i, (n + 3) / 2 - 1, n) {
      int j = n - i;
      if (i < j && s[i] != s[j]) ok = false;
   }
   if (ok)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int N,A,B;
	int n,a,b;
	string str;
	cin >> N >> A >> B;
	cin >> str;
	n = a = b = 0;
	for(int i = 0;i < str.length();i++){
		if(n < A + B){
			if(str[i] == 'a'){
				cout << "Yes" << endl;
				n++;
				a++;
			}else if(str[i] == 'b'){
				if(b < B){
					cout << "Yes" << endl;
					n++;
					b++;
				}else{
					cout << "No" << endl;
				}
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	vector<pii> v(n);
	FOR(i,0,n){
		int a;
		cin>>a;
		v[i]=MP(a,i+1);
	}
	sort(v.begin(),v.end());
	FOR(i,0,n){
		cout<<v[i].ND<<" ";
	}

	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll a,b,n; cin >> a >> b >> n;
    ll first = a*min(b-1,n)/b;
    ll second = a*floor(min(b-1,n)/b);
    cout << first - second << endl;
}


Measured memory_bytes: 3620
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    sort(AS);
    long sum = AS[0];
    int c = 1;
    foreach (a; AS[1..$]) {
        if (sum*2 < a) {
            N -= c;
            c = 0;
        }
        ++c;
        sum += a;
    }
    writeln(N);
}

Measured memory_bytes: 4348
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int a,c,b,ya;
	        ya=0;
	            a = sc.nextInt();
	            b = sc.nextInt();
	            c=sc.nextInt();
	            for(int i=a;i<=b;i++) {
	            	if(c%i==0)
	            		ya++;
	            }
	            sc.close();System.out.println(ya);
	    }
	}


Measured memory_bytes: 26248
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

ll sum[200000 + 1];
//ll c[200000];

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

    int N;
    cin >> N;

    sum[0] = 0;

    for (int i = 1; i <= N; ++i) {
        cin >> sum[i];
        sum[i] += sum[i - 1];
    }

    map<ll, ll> c;
    set<ll> t;

    for (int i = 0; i <= N; ++i) {
        ++c[sum[i]];
        t.insert(sum[i]);
    }

    ll ans = 0;

    for (ll i : t) {
        ans += c[i] * (c[i] - 1) / 2;
    }

    out(ans);

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 23680