akhauriyash/Code-Regression huggingface dataset:
class Card
  def initialize(mark, value)
    @mark, @value = mark, value
  end

  def description
    "#{@mark} #{@value}"
  end

  attr_reader :value
end

def partition(a, p, r)
  x = a[r]
  i = p - 1
  p.upto(r-1).each {|j|
    if a[j].value <= x.value
      i += 1
      a[i], a[j] = a[j], a[i]
    end
  }
  a[i+1], a[r] = a[r], a[i+1]
  i+1
end

def quick_sort(a, p, r)
  return unless p < r
  q = partition(a, p, r)
  quick_sort(a, p, q-1)
  quick_sort(a, q+1, r)
end

def extract_duplicate(cards)
  dups = cards.group_by{|c| c.value}.reject{|k,v| v.one?}
  dups.keys.sort.map {|k| dups[k].map(&:description)}
end

def is_stable?(org_dup, other_dup)
  org_dup == other_dup ? "Stable" : "Not stable"
end

n = gets.to_i
a = 1.upto(n).map{
  tmp = gets.split
  Card.new tmp[0], tmp[1].to_i
}
o_dup = extract_duplicate a
quick_sort(a, 0, n - 1)
s_dup = extract_duplicate a
puts is_stable? o_dup, s_dup
puts a.map(&:description).join("\n")

Measured memory_bytes: 47168
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 200000 + 3, inf = 1e9 + 10;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	string s; cin >> s;

	if (s[2] == s[3] and s[4] == s[5])cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

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

using namespace std;
#define BUF (200005)
#define ll long long 

int n,k;
int v[BUF];
int cnt=0;

bool asc( int left, int right ) {
    return left  > right;
}



int main(void){
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		int tmp;
		cin >> tmp;
		if(v[tmp]==0)cnt++;
		v[tmp]++;
	}

	sort(v+1,v+n+1,asc);
	//cout << cnt;	
	//for(int i=1;i<=n;i++) cout << v[i];

	int ans = 0;
	for(int i=k+1;i<=n;i++){
		if(v[i]==0) break;
		ans += v[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static final int INF = 1 << 30;

    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String line[] = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int m = Integer.parseInt(line[1]);
            if(n==0){break;}

            int[][][] stone = new int[10][n][2];
            int[][][] table = new int[10][n][m+1];
            for(int i=0; i<10; i++){
                for(int j=1; j<n; j++){
                    for(int k=0; k<=m; k++){
                        table[i][j][k] = INF;
                    }
                }
            }
            if(m > 0){
                for(int i=0; i<10; i++){
                    table[i][1][1] = 0;
                }
            }

            for (int i=0; i<n; i++){
                String info[] = br.readLine().split(" ");
                int num = Integer.parseInt(info[0]);
                for(int j=0; j<num; j++){
                    stone[j][i][0] = Integer.parseInt(info[2*j+1]);
                    stone[j][i][1] = Integer.parseInt(info[2*j+2]);
                }
            }

            for(int k=0; k<=m; k++){
                for(int j=1; j<n; j++){
                    for(int i=0; i<10; i++){
                        if(stone[i][j][0] != 0){
                            for(int l=0; l<10; l++){
                                if(stone[l][j-1][1] != 0){
                                    table[i][j][k] = Math.min(table[i][j][k], ((stone[i][j][1]+stone[l][j-1][1]) * Math.abs(stone[i][j][0]-stone[l][j-1][0])+ table[l][j-1][k]));
                                }
                                if(j>1 && k>0){
                                    if(stone[l][j-2][1] != 0){
                                        table[i][j][k] = Math.min(table[i][j][k], ((stone[i][j][1]+stone[l][j-2][1]) * Math.abs(stone[i][j][0]-stone[l][j-2][0]) + table[l][j-2][k-1]));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            int answer = INF;
            for(int i=0; i<10; i++){
                for(int k=0; k<=m; k++){
                    if(table[i][n-1][k] != 0){
                        answer = Math.min(answer,table[i][n-1][k]);
                    }
                    if(table[i][n-2][k] != 0){
                    	if(k != m){answer = Math.min(answer,table[i][n-2][k]);}
                    }
                }
            }
            System.out.println(answer);
        }
    }
}

Measured memory_bytes: 38168
#include <bits/stdc++.h>
using namespace std;
int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int n;
	cin>>n;
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    vector <long long> out;
    out.push_back(a*c);
    out.push_back(a*d);
    out.push_back(b*c);
    out.push_back(b*d);
    long int output;
    output = *max_element(out.begin(),out.end());
    cout << output << "\n";
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

bool solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2)return 0;
    REP(i,n/2){
        if(s[i]!=s[i+n/2])return 0;
    }
    return 1;
    

}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    Yes(solve());
}


Measured memory_bytes: 256
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val r, d, x = sc.nextInt
//  val list = List.fill(n + 1)(sc.nextLong)

  val ans = (1 to 10).foldLeft((x, Seq.empty[Long])) { (acc, v) => (acc._1 * r - d, acc._2 :+ (acc._1 * r - d).toLong) }

  ans._2.foreach(f => println(f))
//  println(test(a, b))

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int ans = 1;
        for (int i = n; 0 < i; i--) {
        	int cnt = 0;
        	for (int j = 2;; j *= 2) {
        		if (i % j == 0) {
        			cnt = j;
        		} else {
        			break;
        		}
        	}
        	ans = Math.max(ans, cnt);
		}
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
import bisect
read = input
bisect_right = bisect.bisect_right
# @ see https://docs.python.org/zh-cn/3/library/bisect.html
a ,b , q = map(int, read().split())
INF = 10**18
A =[-INF] + [int(read()) for i in range(a)] +[INF]
B =[-INF] + [int(read()) for i in range(b)] +[INF]
A.sort()
B.sort()
try:
    for i in range(q):
        x = int(read())
        sa = bisect_right(A, x)
        sb = bisect_right(B, x)
        ans = INF
        for pa in [A[sa - 1 ], A[sa]]:
            for pb in [B[sb - 1 ], B[sb]]:
                d1 = abs(x - pa) + abs(pa - pb)
                d2 = abs(x - pb) + abs(pb - pa)
                ans = min(ans, d1, d2)
        print(ans)
except:
    print(x, sa, sb)

Measured memory_bytes: 12800
# include<iostream>
# include<cstring>
# include<cstdio>
# include<cstdlib>
# include<algorithm>
# define LL long long
using namespace std;
const int MAX=2e5+1;
int n;
int a[MAX];
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	  cin>>a[i],a[i]-=i;
	sort(a+1,a+1+n);
	int mid=n/2+1;
	LL ans=0;
	for(int i=1;i<=n;++i)
	  ans+=abs(a[i]-a[mid]);
	if(n%2==0)
	{
		LL minn=0;
		for(int i=1;i<=n;++i)
		  minn+=abs(a[i]-a[mid-1]);
		printf("%lld",min(minn,ans));
	}
	else printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i, N) cin >> V[i];
    vector<int> V0 = V;
    sort(all(V0));
    int ans = 0;
    rep(i, N) {
        int a = V[i];
        int j = lower_bound(all(V0), a) - V0.begin();
        if((j - i) % 2 != 0) ans++;
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 1e5 + 5, inf = 1e9 + 7;
int n;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	n = s.size();
	for (int i = 0; i + 1 < n; i++)
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << "\n";
			return 0;
		}

	for (int i = 0; i + 2 < n; i++)
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << "\n";
			return 0;
		}

	cout << "-1 -1\n";
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 1000010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

inline void solve(ll &x, ll &y, ll a, ll b)
{
	ll l=1,r=INF/(a+b),mid;
	while(l<r)
	{
		mid=(l+r)/2;
		if (a*mid>=x&&b*mid>=y) r=mid;
		else l=mid+1;
	}
	mid=(l+r)/2;
	x=a*mid;
	y=b*mid;
}

int main()
{
	ll n,x,y,t,a;
	scanf("%lld",&n);
	REP(i,n)
	{
		scanf("%lld%lld",&t,&a);
		if (!i)
		{
			x=t;
			y=a;
		}
		else
			solve(x,y,t,a);
	}
	printf("%lld\n",x+y);
return 0;
}


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

int main(){
	int N, T;
	cin >> N >> T;
	int t[N];
	int ans = 0;
	int time;
	for(int i = 0; i < N; ++i){
		cin >> t[i];	
	}
	
	for(int i = 0; i < N - 1; ++i){
		time = t[i];
		if(t[i + 1] - t[i] >= T){
			ans += T;	
		}else{
			ans += t[i + 1] - t[i];
		}
	}
	
	ans += T;
	
	cout << ans << endl;
	
	
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;


int main() {
    int N,sum = 0,a;
    cin >> N;
    int N1 = N;
    for(int i = 1;i <= 100;i++){
        a = N % 10;
        N = N / 10;
        sum = sum + a;
    }
    if(N1 % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
    long long int N,A[200000],i,max=0,max2=0;
    scanf("%lld",&N);

    for(i=0; i<N; i++)
    {
        scanf("%lld",&A[i]);
        if(A[i]>max)
            max=A[i];
        else if(A[i]>max2)
            max2=A[i];
    }

    for(i=0; i<N; i++)
    {
        if(A[i]==max)
        {
            printf("%d\n",max2);
            continue;
        }
        printf("%d\n",max);
    }
    return 0;
}



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

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a<=c && c<=b && b<=d){
        cout << b-c << endl;
    }else if(c<=a && a<=d && d<=b){
        cout << d-a << endl;
    }else if(a<=c && d<=b){
        cout << d-c << endl;
    }else if(c<=a && b<=d){
        cout << b-a << endl;
    }else{
        cout << 0 << endl;
    }
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int main(){
    int n;
    int a,b;
    cin>>n;
    a=n%3;

    b=(n-a)/3;


    cout<<b<<endl;
    
    

    return 0;
}

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

        int N = scanner.nextInt();
        int k = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }
        java.util.Arrays.sort(a);
        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += a[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 38748
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
struct A
{
	ll a,b;
}bug[300005];
bool comp(const A& aa,const A& bb)
{
	if(aa.b!=bb.b) return aa.b>bb.b;
	return aa.a<=bb.a;
}

ll bit[(1<<17)+1]={};
ll bit2[(1<<17)+1]={};
int v[(1<<17)]={};
void add(int i,ll x)
{
	while(i<=(1<<17))
	{
		bit[i]+=x;
		i += i & -i;
	}
}
void add2(int i,ll x)
{
	while(i<=(1<<17))
	{
		bit2[i]+=x;
		i += i & -i;
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&bug[i].a,&bug[i].b);
	}
	sort(bug,bug+n,comp);
	int ret=0;
	for(int i=0;i<n;i++)
	{
		ll bord=bug[i].b;
		add((int)bug[i].a,bug[i].a);
		add2((int)bug[i].a,1LL);
		v[bug[i].a]++;
		ll now=0;
		ll many=0;
		int nowid=0;
		int id=(1<<17);
		while(id>0 && nowid+id<=(1<<17))
		{
			if(now+bit[nowid+id]<=bord*(1LL*many+bit2[nowid+id]))
			{
				now+=bit[nowid+id];
				many+=bit2[nowid+id];
				nowid+=id;
			}
			else
			{
				for(int j=1;j<v[nowid+id];j++) {if(now+bit[nowid+id]-(nowid+id)*j<=bord*(1LL*many+bit2[nowid+id]-j)) { many=1LL*many+bit2[nowid+id]-j; goto f;}}


			}
			id/=2;
		}
		f:;
		ret=max(ret,(int)many);
	}
	printf("%d\n",ret);
}

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

using namespace std;
int a[200100];

int main()
{
    int n;  cin >> n;
    for(int i = 0;i<n;i++)  cin >> a[i];
    int Min = 1e9,Ans = 0;
    for(int i = 0;i<n;i++){
        if(a[i] < Min)  Ans++;
        Min = min(Min , a[i]);
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int bit[26][500010]={};

void bitAdd(char c, int n, int a){
	int d=c-'a';
	for(int i=n; i<500010; i += i&(-i)){
		bit[d][i] += a;
	}
}

int bitSum(char c, int n){
	int res=0, d=c-'a';
	for(int i=n; i>0; i -= i&(-i)){
		res += bit[d][i];
	}
	return res;
}

int main() {
	int N;
	string S;
	int Q;
	cin >> N >> S >> Q;
	for(int i=0; i<N; ++i){
		bitAdd(S[i], i+1, 1);
	}
	for(int q=0; q<Q; ++q){
		int choku;
		cin >> choku;
		if(choku==1){
			int i;
			cin >> i;
			bitAdd(S[i-1], i, -1);
			cin >> S[i-1];
			bitAdd(S[i-1], i, 1);
		}else{
			int l, r, ans=0;
			cin >> l >> r;
			for(int i=0; i<26; ++i){
				if(bitSum('a'+i, r)>bitSum('a'+i, l-1)) ++ans;
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 51716
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)

using ll = long long;


int main() {
    ll n, m, k; std::cin >> n >> m >> k;
    std::vector<ll> a(n+1, 0), b(m+1, 0);
    rep(i,n) {
        ll tmp; std::cin >> tmp;
        a[i+1] = a[i]+tmp;
    }
    rep(i,m) {
        ll tmp; std::cin >> tmp;
        b[i+1] = b[i]+tmp;
    }

    ll j=m, i=0, ans=0;
    for(i=0; i<n+1; ++i) {
        if (a[i] > k) break;
        while (j >= 0 && b[j] > k - a[i]) --j;
        ans = std::max(ans, i+j);
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = nint();
        int T = nint();
        int[] t = nints(N);
        
        long ans = 0;
        long time = 0;
        
        for (int i = 0; i < N; i++) {
            if (time > t[i]) {
                ans += T - (time-t[i]);
                time += T - (time-t[i]);
            } else {
                time = t[i] + T;
                ans += T;
            }
        }
        
        System.out.println(ans);
    }
    
    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}

Measured memory_bytes: 62600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int a[1000010],b[1000010];
int main()
{
	int q,l,r;
	scanf("%d",&q);
	for(int i=2;i<=100010;i++)
	{
		for(int j=i*2;j<=100010;j+=i)
		{
			a[j]=1;
		}
	}
	for(int i=3;i<=100010;i++)
	{
		b[i]+=b[i-1];
		if(a[i])
			continue;
		r=(i+1)/2;
		if(!a[r])
		{
//printf("%d %d\n",i,r);
			b[i]++;
		}
	}
	for(int i=0;i<q;i++)
	{
		scanf("%d%d",&l,&r);
		printf("%d\n",b[r]-b[l-1]);
	}
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> D;
    for (int i = 0; i < N; i++)
    {
        int d;
        cin >> d;
        if (count(D.begin(), D.end(), d) == 0)
        {
            D.push_back(d);
        }
    }
    cout << D.size() << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int n,a[200000],ans;
map<int,int> m;

signed main() {
    cin >> n;
    rep(i,n) cin >> a[i], m[a[i]]++;
    for(auto i : m) {
        if (i.se >= 2) ans += i.se*(i.se-1)/2;
    }
    rep(i,n) {
        int b = m[a[i]];
        int hoge = ans;
        hoge -= b*(b-1)/2;
        if (b > 2) hoge += (b-1)*(b-2)/2;
        cout << hoge << endl;
    }
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int a[maxn], pos[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        pos[a[i]] = i;
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        if (a[i] != i){
            swap(a[i], a[pos[i]]);
            ++cnt;
        }
    }
    if (cnt > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

int main() {

  int q;
  cin >> q;

  deque<int> A;
  for (int i = 0; i < q; i++) {
    int query, d, x;
    cin >> query;
    if (query == 0) {
      cin >> d >> x;
      if (d == 0) {
        A.push_front(x);
      } else {
        A.push_back(x);
      }
    } else if (query == 1) {
      cin >> d;
      cout << A[d] << endl;
    } else {
      cin >> d;
      if (d == 0) {
        A.pop_front();
      } else {
        A.pop_back();
      }
    }
  }

  return 0;

}


Measured memory_bytes: 4660
n, m = map(int, input().split())
servey = []
for i in range(n):
    k_a = list(map(int, input().split()))
    servey.append(k_a)
for j in servey:
    del j[0]
loves = []
for x in range(1, m+1):
    count = 0
    for y in servey:
        if x in y:
            count+=1
        loves.append(count)
food_count = 0     
for z in loves:
    if z == n:
        food_count += 1

print(food_count)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
	ll K, N;
	cin >> K >> N;
	vector<int> a(N), diff(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N-1; i++) {
		diff[i] = a[i + 1] - a[i];
	}
	diff[N - 1] = a[0] + K - a[N-1];

	cout << K - *(max_element(diff.begin(), diff.end())) << endl;
}

Measured memory_bytes: 4820
#include<iostream>
#include<set>
#include<algorithm>
typedef long long ll;
using namespace std;
int main() 
{
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if (s=="ARC")
		cout<<"ABC";
	else
		cout<<"ARC";
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int n,i,j,u,k,v;
  int G[101][101];

  scanf("%d",&n);

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
    G[i][j]=0;
    }
  }
  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
      G[u][v]=1;
    }
  }
  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      if(j==n)printf("%d\n",G[i][j]);
      
     else printf("%d ",G[i][j]);
    }
  }
  return 0;
}




Measured memory_bytes: 2112
"use strict";

let input = require("fs").readFileSync("/dev/stdin", "utf8");
const info = input.trim().split('\n');
const nums = info[1].split(' ').map(x => x*1);
// 平均値出す
const ave = Math.round( nums.reduce((x,a) => {return a += x}) / info[0] );
let sum = 0;
for(let i = 0; i < info[0]; i++){
  sum += Math.pow( nums[i] - ave ,2 )
}
console.log(sum);

Measured memory_bytes: 7372
import collections
INF = 10**9
    
def next(H,W,S,current):
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    for i in range(4):
        neighbor = (current[0]+dx[i],current[1]+dy[i])
        if 0 <= neighbor[0] < H and 0 <= neighbor[1] < W and S[neighbor[0]][neighbor[1]] == '.':
            yield neighbor

def bfs(start,H,W,S):
    q = collections.deque([start])
    v = 0
    visited = []
    layer = [[INF for i in range(W)] for j in range(H)]
    layer[start[0]][start[1]] = 0
    while q:
        c = q.popleft()
        if c in visited:
            continue
        visited.append(c)
        for neighbor in next(H,W,S,c):
            if neighbor not in visited:
                q.append(neighbor)
                layer[neighbor[0]][neighbor[1]] = layer[c[0]][c[1]]+1
                v = max(v,layer[neighbor[0]][neighbor[1]])
    #print(layer,start)
    return v

def main():
    H,W  = map(int, input().split())
    S = [[] for i in range(H)]
    route = 0
    for i in range(H):
        S[i]  = list(input())
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                start = (i,j)
                route = max(route,bfs(start,H,W,S))
    print(route)

if __name__ == '__main__':
    main()                


Measured memory_bytes: 61528
import java.util.*;

public class Main {
	
	int INF = 1 << 24;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0 ) break;
			int [][] data = new int[n][n+1];
			for(int i=0; i < n; i++){
				for(int j = 0; j < n+1; j++){
					data[i][j] = sc.nextInt();
				}
			}
			int len = 1 << n;
			int [] dp = new int[len];
			Arrays.fill(dp, INF);
			dp[0] = 0;
			
			for(int i=0; i < len; i++){
				for(int j = 0;j < n; j++){
					if((i & (1 << j)) == 0){
						//not use
						int ind = i | (1 << j) ;
						int value = dp[i] + data[j][0];
						dp[ind] = Math.min(dp[ind], value);
						//use
						for(int k = 0; k < n; k++){
							if((i & (1 << k)) == 0) continue;
							value = dp[i] + data[j][k+1];
							dp[ind] = Math.min(dp[ind], value);
						}
					}
				}
			}
			System.out.println(dp[len-1]);
		}
		
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  var wa=0
  for(var i=0; i<input.length; i++){
    wa+=Number(input.substr(i,1))
  }
  if(n%wa==0){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int main()
{
    int a,b,sum=0,q=0,A=0,B=0;
    cin>>a>>b;
    if(a!=b)
    {
        if(a<0&&b>0){
                A=-a;
                B=b;
            sum=(A+B)%2;
            q=(A+B)/2;
        }
        else if(a>0&&b<0)
        {
                A=a;
                B=-b;
            sum=(A+B)%2;
            q=(A+B)/2;
        }
        else if(a<0&&b<0)
        {
                A=-a;
                B=-b;
            sum=(A+B)%2;
            q=(A+B)/2;
        }
        else
        {
            sum=(a+b)%2;
            q=(a+b)/2;
        }

        if(sum==0)
        {
            cout<<q;
        }
        else
            cout<<"IMPOSSIBLE";
    }
}


Measured memory_bytes: 256
from collections import deque
import sys
input=sys.stdin.readline


def solve():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())

    l = [[1 if i=="#" else 0 for i in input()] for _ in range(H)]
    q = deque([(0, (Ch-1, Cw-1))])
    INF = 10**12
    costs = [[INF]*W for _ in range(H)]
    costs[Ch-1][Cw-1] = 0

    while q:
        cost, pos = q.popleft()
        h, w = pos
        for dh in range(-2, 3):
            for dw in range(-2, 3):
                hh, ww = h+dh, w+dw
                if not (0<=hh<H and 0<=ww<W):
                    continue
                if l[hh][ww]:
                    continue
                
                if ((abs(dh)==1 and dw==0) or (dh==0 and abs(dw)==1)) and costs[hh][ww] > costs[h][w]:
                    costs[hh][ww] = costs[h][w]
                    q.appendleft((cost, (hh, ww)))
                elif costs[hh][ww] > costs[h][w]+1:
                    costs[hh][ww] = costs[h][w]+1
                    q.append((cost+1, (hh, ww)))

    ans = costs[Dh-1][Dw-1]
    print(ans if ans!=INF else -1)


solve()


Measured memory_bytes: 122280
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 3005;

int power(int x,int y){
    int res=1;
    x%=mod;
    while(y>0){
        if(y&1)
            res=(res*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return res;
}
 
int modinv(int n){
    return power(n,mod-2);
}

int i,j,n,s,a[N],dp[N][N];

void solve(){
    cin>>n>>s;
    for(i=1;i<=n;++i){
        cin>>a[i];
    }
    dp[0][0]=power(2,n);
    for(i=1;i<=n;++i){
        for(j=0;j<=s;++j){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
            if(j>=a[i]){
                dp[i][j]+=dp[i-1][j-a[i]]*modinv(2);
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[n][s];
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 74112
#include <bits/stdc++.h>
#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++)
using namespace std;
int main() {
  long k,a,b;
  cin>>k>>a>>b;
  
  
  rep2(i,a,b+1){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define f(a,b) for( long long int i= a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll  long long
using namespace std;
int main()
{
    ll t,q,a,b,n;
    string s[100000];
    cin>>n;
      map<string,ll>m;
      f(0,n-1)
      {
          cin>>s[i];
          m[s[i]]++;
      }
      cout<<"AC x "<<m["AC"]<<endl;
      cout<<"WA x "<<m["WA"]<<endl;
      cout<<"TLE x "<<m["TLE"]<<endl;
      cout<<"RE x "<<m["RE"]<<endl;
cout<<endl;
             return 0;
}
















Measured memory_bytes: 6752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count = 0; 
		for(int i = 0; i <= K ; i ++){
			for(int j = 0; j <= K ; j ++){
				if( 0 <=  S - i - j  && S - i - j  <= K ){
						count++;
				}
			}
		}
		System.out.println(count);
	}
}


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

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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

const int T = 102;
ll v[T];
int n;

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

    ll mmc = 1;
    ll den = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        mmc = (mmc*v[i])/__gcd(mmc,v[i]);
    }

    for(int i = 0; i < n; i++) den += mmc/v[i];

    double ans = (double)mmc/(double)den;

    cout << fixed << setprecision(5) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace _100_1
{
    class Program
    {
        static void Main(string[] args)
        {
			string[] str = Console.ReadLine().Split(' ');
			int A = int.Parse(str[0]);
			int B = int.Parse(str[1]);
			if(A > 8.5)
			{
				Console.WriteLine(":(");
			}
			else if(B > 8.5)
			{
				Console.WriteLine(":(");
			}
			else
			{
				Console.WriteLine("Yay!");
			}
			Console.ReadLine();

		}
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(void)
{
	int n,i,j,k,sum,p,x1,x2;
	int a[1001][8];
	char suke[1001];
	
	scanf("%d",&n);
	scanf("%s",suke);
	if(suke[0]=='J') p=4;
	else if(suke[0]=='O') p=2;
	else p=1;
	for(i=0;i<n;i++){
		for(j=0;j<8;j++){
			a[i][j]=0;
		}
	}
	for(i=0;i<8;i++){
		x1=i&4;	x2=i&p;
		if(x1==4 && x2==p){
			a[0][i]=1;
		}
	}	
	for(i=1;i<n;i++){
		if(suke[i]=='J') p=4;
		else if(suke[i]=='O') p=2;
		else p=1;
		for(j=1;j<8;j++){
			for(k=1;k<8;k++){
				x1=j&p;	x2=j&k;
				if(x1!=0 && x2!=0){
					a[i][j]+=a[i-1][k];
				}
			}
			a[i][j]%=10007;
		}
	}
	/*for(i=0;i<n;i++){
		for(j=0;j<8;j++){
			printf("%d",a[i][j]);
		}
		printf("\n");
	}*/
	sum=0;
	for(i=1;i<8;i++){
		sum+=a[n-1][i];
	}
	sum%=10007;
	printf("%d\n",sum);
	return 0;
}	

Measured memory_bytes: 2784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(int i=x;i<n;i++)

int N, W, A[102][2];
ll dp[102][100002], ans = 0;
//unordered_set<int>sack;
bool sack[100002];
int main()
{
    cin >> N >> W;
    //sack.push_back(W);
    //sack.insert(W);
    sack[W] = 1;
    loop(i,0, N)
    {
        cin >> A[i][0] >> A[i][1];
    }
    loop(i,1,N+1)
    {
        loop(j, 0, W+1)
        {
            if (sack[j])
            {
                //cout << sack[j] << " ";
                dp[i][j] = dp[i - 1][j];
                if (j >= A[i - 1][0])
                {
                    dp[i][j - A[i - 1][0]] = max(dp[i - 1][j - A[i - 1][0]], dp[i - 1][j] + A[i - 1][1]);
                    sack[j - A[i - 1][0]] = 1;
                }
            }
        }
    }
    loop(i, 0, W)
    {
        ans = max(ans, dp[N][i]);
    }
    cout << ans;
}



Measured memory_bytes: 77312
using System;
using System.Linq;

namespace abc126_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            var N = NK[0];
            var K = NK[1];
            double r = 0;

            for(int i = 1; i<= N; i++) 
            {
                if (i >= K)
                {
                    r += (1D / (double)N);
                }
                else 
                {
                    var x = Math.Ceiling(Math.Log(K, 2) - Math.Log(i, 2));
                    r += (1D / (double)N) * (1D / Math.Pow(2, x));
                }
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 11220
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define whole(xs) xs.begin(), xs.end()
typedef long long ll;
struct S {
    int d, p;
};
ostream& operator<<(ostream& os, const S& s) {
    os << "S: " << s.d << " " << s.p;
    return os;
}
bool comp(const S &a, const S &b) {
    return b.p < a.p;
}
int N, M; 
vector<S> v;

bool input() {
    cin >> N >> M;
    if (N == 0 && M == 0) return false;
    v.clear(); v.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].d >> v[i].p;
    }
    return true;
}

int main() {
    while (input()) {
        ll ans = 0;
        sort(whole(v), comp);
        for (int i = 0; i < v.size(); i++) {
            if (M >= v[i].d) {
                M -= v[i].d;
            } else {
                ans += (v[i].d - M) * v[i].p;
                M = 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1340
#include <stdio.h>

int main(void) {
    int H, W;
    scanf("%d %d", &H, &W);

    char S[H][W];
    for (int i = 0; i < H; i++) {
        scanf("%s", S[i]);
    }

    int A[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            A[i][j] = 0;
        }
    }


    int offset[8][2] = {
        {0, 1},
        {0, -1},
        {1, 0},
        {1, 1},
        {1, -1},
        {-1, 0},
        {-1, 1},
        {-1, -1},
    };

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                A[i][j] = -100;
                continue;
            }

            for (int d = 0; d < 8; d++) {
                int x = i + offset[d][0];
                int y = j + offset[d][1];

                if (x < 0 || x >= H) {
                    continue;
                }

                if (y < 0 || y >= W) {
                    continue;
                }

                if (S[x][y] == '#') {
                    A[i][j]++;
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] >= 0) {
                printf("%d", A[i][j]);
            } else {
                printf("#");
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 128
import Foundation

extension String {
    func toIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }
    
    func toList() -> [String] {
        return self.map{String($0)}
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}


func disco2020c() {
    let HWK = readLine()!.toIntList()
    let H = HWK[0]
    let W = HWK[1]
    var K = HWK[2]
    var G:[[String]] = []
    var ANS:[[Int]] = Array(repeating: Array(repeating: 0, count: W), count: H)
    for y in 1...H{
        let x = readLine()!.toList()
        G.append(x)
    }
    var isInStbY = false
    var width:[Int] = []
    var yLists:[[Int]] = []
    var list:[Int] = []

    var i = 0
    for y in 0..<H{
        if G[y].contains("#"){
            list.append(y)
            i = y+1
            break
        }
        list.append(y)
    }
    
    for y in i..<H{
        if G[y].contains("#"){
            yLists.append(list)
            list = [y]
        }else{
            list.append(y)
        }
    }
    if list.count > 0 {
        yLists.append(list)
    }
    
    func isInStrovery(_ yList:[Int],_ x:Int) -> Bool{
        for y in yList{
            if G[y][x].contains("#"){
                return true
            }
        }
        return false
    }
    for (index,yList) in yLists.enumerated(){
        var xLists:[[Int]] = []
        var xlist:[Int] = []
        var isInStbX = false
        
        var i = 0
        for x in 0..<W{
            if isInStrovery(yList, x){
                xlist.append(x)
                i = x+1
                break
            }
            xlist.append(x)
        }
        
        for x in i..<W{
            if isInStrovery(yList, x){
                xLists.append(xlist)
                xlist = [x]
            }else{
                xlist.append(x)
            }
        }
        if xlist.count > 0 {xLists.append(xlist)}
        
        
        for xlist in xLists{
            for x in xlist{
                for y in yList{
                    ANS[y][x] = K
                }
            }
            K -= 1
        }
    }
    
    for y in 0..<H{
        for x in 0..<W{
            print(ANS[y][x],terminator: " ")
        }
        print("")
    }
}

disco2020c()


Measured memory_bytes: 16612
n, m, x = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
  c_as = list(map(int, input().split()))
  c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
  
for s in range(0, 1 << n):
  skill = [0] * m
  money = 0
  for i in range(n):
    if(s >> i) % 2 == 0:continue
    money += c[i]
    for j in range(m):
      skill[j] += A[i][j]
  ok = True
  for j in range(m):
    if skill[j] < x:
      ok = False
  if ok:
    ans = min(ans, money)
    
if ans == INF:
  ans = -1
  
print(ans)

Measured memory_bytes: 9184
S = input()
div = 10**9 + 7

lenS = len(S)
dp = [[0]*13 for _ in range(lenS+1)]

ini = S[0]
if ini=='?':
    for i in range(10):
        dp[1][i] = 1
else:
    dp[1][int(ini)] = 1

for i in range(2, lenS+1):
    chara = S[i-1]
    if chara=='?':
        for d in range(13):
            for e in range(10):
                newd = (d*10+e)%13
                dp[i][newd] = (dp[i][newd]+dp[i-1][d])%div
    else:
        for d in range(13):
            newd = (d*10+int(chara))%13
            dp[i][newd] = (dp[i][newd]+dp[i-1][d])%div

print(dp[-1][5])

Measured memory_bytes: 61916
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int ans[110000];

int main(){
  vector<int> V;
  int H[110000];
  string S;
  cin>>S;
  string check="RL";
  int hantei=0,temp=0;
  for(int i=0;i<S.size();i++){
    if(S[i]==check[hantei]) temp++;
    else{
      V.push_back(temp);
      hantei=(hantei+1)%2;
      temp=1;
    }
    if(i==S.size()-1) V.push_back(temp);
  }
  hantei=0;
  int sum=0;
  for(int i=0;i<V.size();i++,hantei=(hantei+1)%2){
    if(hantei==0){
      sum+=V[i];
      ans[sum-1]+=(V[i]+1)/2;
      ans[sum]+=V[i]/2;
    }else{
      ans[sum]+=(V[i]+1)/2;
      ans[sum-1]+=V[i]/2;
      sum+=V[i];
    }
    
  }
  cout<<ans[0];
  for(int i=1;i<S.size();i++){
    cout<<" "<<ans[i];
  }
  
  cout<<endl;
}


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

int main()
{
    int n;
    cin>>n;
    int num[n];
    for (int i = n-1; i >=0; i--) {
        cin>>num[i];
    }
    for (int i = 0; i < n-1; i++) {
      cout << num[i]<<" ";
    }
    cout << num[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3132
program sushi
implicit none

integer(8) :: i,j,k
integer(8) :: n,c
integer(8) :: x(200000)=0,v(200000)=0
integer(8) :: v_sum_a(200000)=0,v_sum_b(200000)=0
integer(8) :: ans1=0,ans2=0,ans3=0,ans4=0
integer(8) :: ans2_a(0:200000)=0,ans2_b(0:200000)=0,ans4_a(0:200000)=0,ans4_b(0:200000)=0
integer(8) :: val=0,ans2_best=0,ans4_best=0,ans=0

read(*,*) n,c

do i= 1,n
	read(*,*) x(i),v(i)
enddo

!時計周りに回した時のカロリー累積和
do i=1,n
	if(i == 1) then
		v_sum_a(i) = v(1)
	else
		v_sum_a(i) = v_sum_a(i-1) + v(i)
	endif
enddo

!反時計周りに回した時のカロリー累積和
do i=n,1,-1
	if(i == n) then
		v_sum_b(i) = v(n)
	else
		v_sum_b(i) = v_sum_b(i+1) + v(i)
	endif
enddo



!ans1 : 時計回りに進んで終了
do i=1,n
	ans1 = max(ans1,v_sum_a(i)-x(i))
enddo

!ans2 : 時計回りに進んでから、反時計回りに戻る
!まずは時計回りの最適値を求める。
!1～i番目の寿司の間で自由に取れて原点まで戻ったときの、カロリーの最大値
do i = 1,n
	val = v_sum_a(i) - 2 * x(i)
	ans2_a(i) = max(ans2_a(i-1),val)
enddo

!反時計周りでi～nまで取れるときの最大値
do i=n,1,-1
	val = v_sum_b(i) - (c - x(i))
	ans2_b(i) = max(ans2_b(i+1),val)
enddo

do i=0,n
	val = ans2_a(i) + ans2_b(i+1)
	ans2 = max(ans2,val)
enddo

!ans3 : 反時計回りに進んで終了
do i=1,n
	ans3 = max(ans3,v_sum_b(i)-(c-x(i)))
enddo

!ans4 : 反時計回りに進んでから、時計回りに戻る
!まずは時計回りの最適値を求める。
do i = 1,n
	val = v_sum_a(i) - x(i)
	ans4_a(i) = max(ans4_a(i-1),val)
enddo

!反時計周りでi～nまで取れるときの最大値
do i=n,1,-1
	val = v_sum_b(i) - 2 * (c - x(i))
	ans4_b(i) = max(ans4_b(i+1),val)
enddo

do i=0,n
	val = ans4_a(i) + ans4_b(i+1)
	ans4 = max(ans4,val)
enddo

ans = max(ans2,ans4)
write(*,*) ans

end program

Measured memory_bytes: 11776
H, W = map(int, input().split())
S = ['.'*(W+2)]+['.'+input()+'.' for _ in range(H)]+['.'*(W+2)]
flag = True

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j]=='#' and S[i-1][j]=='.' and S[i+1][j]=='.' and S[i][j-1]=='.' and S[i][j+1]=='.':
            flag = False

if flag:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if(A <= C && C <= B){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i,n) for (int i=0;i<(n);++i)

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 main(){
    string S;cin >> S;
    int count = 0;

    if (S.compare("RRR")==0) {
        cout << "3" <<endl;
    } else if (S.compare("RRS")==0) {
        cout << "2" <<endl;
    } else if (S.compare("SRR")==0) {
        cout << "2" <<endl;
    } else if (S.compare("RSR")==0) {
        cout << "1" <<endl;
    } else if (S.compare("SSR")==0) {
        cout << "1" <<endl;
    } else if (S.compare("SRS")==0) {
        cout << "1" <<endl;
    } else if (S.compare("RSS")==0) {
        cout << "1" <<endl;
    } else {
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624