akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair <int,int> P;
string mp[501];
int m,n,used[30],ans;
vector <P>  a[30];

int saiki(int);

bool check_x(int y,int x1,int x2){
  for(int i=x1+1;i<x2;i++)
    if(mp[y][i]!='.'&&!saiki(mp[y][i]-'A'))return 0;
  return 1;
}

bool check_y(int y1,int y2,int x){
  for(int i=y1+1;i<y2;i++)
    if(mp[i][x]!='.'&&!saiki(mp[i][x]-'A')) return 0;
  return 1;
}


int saiki(int ch){  
  int x1=a[ch][0].x,x2=a[ch][1].x;
  int y1=a[ch][0].y,y2=a[ch][1].y;
  int res=0;
  if(used[ch])return 0;
  used[ch]=1;
  
  if(x1==x2&&y2-y1!=1) res=check_y(y1,y2,x1);
  if(y1==y2&&x2-x1!=1) res=check_x(y1,x1,x2);

  if(x1!=x2&&y1!=y2) {
    if(x1<x2){
      res=check_x(y1,x1,x2+1)&check_y(y1,y2,x2);
      res|=check_y(y1,y2+1,x1)&check_x(y2,x1,x2);
    }
    else{
      swap(x1,x2);
      res=check_x(y1,x1-1,x2)&check_y(y1,y2,x1);
      res |=check_y(y1,y2,x2)&check_x(y2,x1,x2+1);
      swap(x1,x2);
    }
  }
    

  used[ch]=0;
  if(res) {
    mp[y1][x1]=mp[y2][x2]='.';
    a[ch].clear();
    ans+=2;
    used[ch]=1;
  }

  return res;
}

int main(){

  cin>>m>>n;
  for(int i=0;i<m;i++)cin>>mp[i];

  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      if(mp[i][j]!='.')a[mp[i][j]-'A'].push_back(P(j,i));
  
  
  for(int i=0;i<30;i++)if(a[i].size()) saiki(i);
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1484
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 2005;
const int inf = 1e18;
int n, head[N], tot, dis[N], f[N], siz[N], v[N], ans = inf;
char s[N];
struct node{int to, nex;}a[N << 1];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void init() {for(int i = 1; i <= n; i ++) dis[i] = siz[i] = f[i] = 0;}
void add(int x, int y) {a[++ tot].to = y; a[tot].nex = head[x]; head[x] = tot;}
void dfs(int x, int fa)
{
	siz[x] = v[x]; int pos = 0;
	for(int i = head[x]; i; i = a[i].nex)
	{
		int y = a[i].to; if(y == fa) continue;
		dfs(y, x); siz[x] += siz[y];
		dis[y] += siz[y]; dis[x] += dis[y];
		if(dis[y] > dis[pos]) pos = y;
	}
	if(pos == 0) return f[x] = 0, void();
	if(dis[pos] * 2 <= dis[x]) f[x] = dis[x] / 2;
	else f[x] = dis[x] - dis[pos] + min(f[pos], (2 * dis[pos] - dis[x]) / 2);
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); scanf("%s", s + 1);
	for(int i = 1; i <= n; i ++) v[i] = s[i] - '0';
	for(int i = 1, x, y; i <= n - 1; i ++) {x = read(); y = read(); add(x, y); add(y, x);}
	for(int i = 1; i <= n; i ++)
	{
		init(); dfs(i, 0); if(dis[i] & 1) continue;
		if(f[i] * 2 == dis[i]) ans = min(ans, dis[i] / 2);
	}
	printf("%lld\n", ans == inf ? - 1 : ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 512
N = int(raw_input())
arr = map(int, raw_input().split(" "))

d = {}
for a in arr:
  d[a-1] = d.get(a-1, 0) + 1
  d[a] = d.get(a, 0) + 1
  d[a+1] = d.get(a+1, 0) + 1

answer = 0
for v in d.itervalues():
  if v > answer: answer = v

print answer

Measured memory_bytes: 16364
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
using namespace std;
using ll = long long;
using vt = pair<ll, int>;

constexpr int limit = 1e5;

int n;
int m;
int s, t;
int u[limit+1], v[limit+1];
int a[limit+1], b[limit+1];
ll ymin[limit+1], smin[limit+1];
ll ans[limit+1];

class edge{
public:
  int yen, snuke;
  int to;

  edge(int y, int s, int t){
    yen = y; snuke = s; to = t;
  }
};

void dijkstra_yen(int s, vector<edge>* graph, ll* dis){
  for(int i=1; i<=n; i++) dis[i] = LLONG_MAX;
  
  priority_queue<vt, vector<vt>, greater<vt>> pq;
  dis[s] = 0;
  pq.push({dis[s], s});

  while(!pq.empty()){
    vt now = pq.top();
    pq.pop();
    if(now.first > dis[now.second]) continue;

    int from = now.second;
    for(int i=0; i<graph[from].size(); i++){
      int to = graph[from][i].to;
      int d = graph[from][i].yen;
      if(dis[to] > dis[from] + d){
        dis[to] = dis[from] + d;
        pq.push({dis[to], to});
      }
    }
  }
}

void dijkstra_snuke(int s, vector<edge>* graph, ll* dis){
  for(int i=1; i<=n; i++) dis[i] = LLONG_MAX;

  priority_queue<vt, vector<vt>, greater<vt>> pq;
  dis[s] = 0;
  pq.push({dis[s], s});

  while(!pq.empty()){
    vt now = pq.top();
    pq.pop();
    if(now.first > dis[now.second]) continue;

    int from = now.second;
    for(int i=0; i<graph[from].size(); i++){
      int to = graph[from][i].to;
      int d = graph[from][i].snuke;
      if(dis[to] > dis[from] + d){
        dis[to] = dis[from] + d;
        pq.push({dis[to], to});
      }
    }
  }
}

int main(){
  cin >> n >> m >> s >> t;

  vector<edge> graph[n+1];

  for(int i=1; i<=m; i++){
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    graph[u[i]].push_back(edge(a[i], b[i], v[i]));
    graph[v[i]].push_back(edge(a[i], b[i], u[i]));
  }

  dijkstra_yen(s, graph,  ymin);
  dijkstra_snuke(t, graph, smin);
  
  ll before = 0;
  for(int i=n; i>=1; i--){
    ll tmp = 1e15 - (ymin[i]+smin[i]);
    ans[i] = max(tmp, before);
    before = ans[i];
  }

  for(int i=1; i<=n; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 12312
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int N;
  int A;
    
  cin >> N >> A;
  
  if (((N % 500) < A) || ((N % 500) == A)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,N;
vvd in,dp;
double dfs(int a,int b){
	if(abs(dp[a][b]+1)>EPS)return dp[a][b];
	double out=0;
	rep(i,n)if((a&1<<i)==0){
		double sum=0;
		double p=1;
		loop(j,b,m){
			sum+=p*(1-in[i][j])*dfs(a|1<<i,j);
			p*=in[i][j];
		}
		out=max(out,sum+p);
	}
	
	return dp[a][b]=out;
}
int main(){
	cin>>n>>m;
	in=vvd(n,vd(m));
	rep(i,n)rep(j,m)cin>>in[i][j];
	N=1<<n;
	dp=vvd(N,vd(m,-1));
	cout<<shosu(11)<<dfs(0,0)<<endl;
}










Measured memory_bytes: 13828
#include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int sum, x, y, ans;
int main(){
 int i, k, v, n, left, right;
 for(i = 2; i <= MAX_V; i++){
  prime[i] = 1;
 }
 for(i = 2; i*i <= MAX_V; i++){
  if(prime[i]){
   for(k = 2 * i; k <= MAX_V; k += i){
    prime[k] = 0;
   }
  }
 }
 while(1){
  scanf("%d", &n);
  if(n == 0) break;
  for(i = 0; i<=n-2; i++){
   x = prime[i];
   y = prime[i + 2];
   if(x == 1 && y == 1){
    ans = i;
   }
  }
  printf("%d %d\n", ans, ans+2);
 }
 return 0;
}

Measured memory_bytes: 6504
import math
N, M = map(int, input().split())
 
def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1 ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
 
divisors = enum_divisors(M, reverse=True)
divisors = list(filter(lambda x: x <= M//N, divisors))

print(divisors[0])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

a,b,k = map(int,input().split())
lists = []

for i in range(a,min(a+k,b+1)):
    lists.append(i)

for i in range(b,max(b-k,a),-1):
    lists.append(i)

l = set(lists)
m = list(l)

m.sort()

for i in m:
    print(i)


Measured memory_bytes: 3060
n = gets.to_i

h = Hash.new(0)
n.times {h[gets.chomp] += 1}

h = h.sort_by{|k,v| -v}
m = h[0][1]

s = []
h.each do |k,v|
    break if m != v
    s << k
end

puts s.sort

Measured memory_bytes: 39744
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
const ll LINF = 1e18;
const ll INF = 1e9;
using namespace std;

ll rec(vector<ll> &A, ll idx) {
    sort(A.begin(), A.end());
    // cout << "-----" << endl;
    // REP(i, A.size()) {
    //     cout << A[i] << endl;
    // }
    // printf("idx=%lld\n", idx);
    ll mn=0;
    for(ll i=idx; i<A.size(); i++) {
        if(A[i]!=0) {
            if(A[i] == 1) {
                return 1;
            } else {
                idx = i;
                mn = A[i];
                // printf("idx=%lld, mn=%lld\n", idx, mn);
                break;
            }
        }
    }

    if (idx == A.size()-1 || mn==0) {
        return mn;
    }

    for(ll i=idx+1; i<A.size(); i++) {
        A[i] %= mn;
    }

    return rec(A, idx);
}

int main() { 
    ll N; cin >> N;
    vector<ll> A;
    REP(i, N) {
        int a; cin >> a;
        A.push_back(a);
    }

    cout << rec(A, 0) << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
long long int c[200005];
int main(){
    int n;
    long long int k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<n+1;i++)cin >> a[i];
    int now=1;
    long long int count=0;
    long long int loop;
    long long int bef;
    while(1){
        if((count>0 && now==1) || c[now]>0){
            loop=count-c[now];
            bef=c[now];
            break;
        }
        else{
            c[now]=count;
            now=a[now];
            count++;
        }
        if(count==k)break;
    }
    if(count==k)cout << now << endl;
    else{
        long long int ans=(k-bef)%loop;
        while(ans>0){
            now=a[now];
            ans--;
        }
        cout << now << endl;
    }
}

Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
int main() {
	init();

	int N; cin >> N;
	vector<ll>vec(N);
	rep(i, 0, N)cin >> vec[i];
	ll cnt = 1;
	rep(i, 0, N) {
		cnt = lcm(cnt, vec[i]);
	}
	cout << cnt << "\n";

	return 0;
}


Measured memory_bytes: 256
X = int(input())

if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
else:
    print(1)
    

Measured memory_bytes: 9168
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')


def sol():
    N = int(input())
    A = [deque()] + [deque(map(int, input().split())) for _ in range(N)]

    days = [0] * (N + 1)
    now = [0] * (N + 1)

    que = deque([i + 1 for i in range(N)])

    while que:
        i = que.popleft()
        if not A[i]:
            continue

        a = A[i].popleft()
        if now[a] == i:
            days[a] = days[i] = max(days[a], days[i]) + 1
            que.append(i)
            que.append(a)
            now[a] = now[i] = 0
        else:
            now[i] = a

    for i in range(1, N + 1):
        if A[i]:
            print(-1)
            return
    print(max(days))


sol()

Measured memory_bytes: 36084
#include"bits/stdc++.h"
using namespace std;

int main()
{
    int a[7];
    for(int i=1;i<=5;i++)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            cout<<i<<endl;
        }
    }
    return 0;


}


Measured memory_bytes: 3632
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int i,j;
  int h,w;
  char a[10][10];

  cin>>h>>w;
  rep(i,h)
    scanf("%s",a[i]);
  rep(j,w)
    a[h][j]='.';
  rep(i,h)
    a[i][w]='.';

  a[0][0]='.';
  i=0;
  j=0;
  while(1){
    if(i==h-1 && j==w-1)break;
    if(a[i][j+1]=='#' && a[i+1][j]=='#'){
      cout<<"Impossible"<<endl;
      return 0;
    }
    if(a[i][j+1]=='.' && a[i+1][j]=='.'){
      cout<<"Impossible"<<endl;
      return 0;
    }
    if(a[i][j+1]=='#'){
      j++;
      a[i][j]='.';
    }else{
      i++;
      a[i][j]='.';
    }
  }
  rep(i,h)rep(j,w)
    if(a[i][j]=='#'){
      cout<<"Impossible"<<endl;
      return 0;
    }
  cout<<"Possible"<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<stack>
#include<iomanip>
#include<functional>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    map<int,int> num;
    rep(i,n-1)
    {
        int a;
        cin>>a;
        num[a-1]+=1;
    }
    rep(i,n)
    {
        cout<<num[i]<<endl;
    }
    
    
}

Measured memory_bytes: 13008
//https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //文字列入力
    string s;
    cin >> s;

    ll ans = 0;
    REP(i, 4)
    {
        if (s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int n, m, s, t;
    cin >> n >> m;
    bool w1[n+10]{}, wn[n+10]{};

    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        if (s == 1) w1[t] = true;
        if (t == n) wn[s] = true;
    }

    for (int i = 2; i < n; i++) {
        if (w1[i] & wn[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 4000
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define int long long
signed main(){
    int n;
    cin >> n;
    vector<int>a(n);
    map<int,int>pos;
    rep(i,n){
        cin >> a[i];
        pos[a[i]] = i;
    }
    set<int>st;
    st.insert(-1);
    st.insert(n);
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        auto it = st.lower_bound(pos[i]);
        int r = *it;
        it--;
        int l = *it;
        ans += (ll)(i * (l-pos[i])*(pos[i]-r));
        st.insert(pos[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 23680
package main
import(
    "fmt"
    )
func main(){
    var human, time [5]float64
    minTime := [2]float64{1000000000000000, -1}
    fmt.Scan(&human[0])
    for i:=0; i<5; i++{
        fmt.Scan(&time[i])
        if minTime[0] > time[i]{
            minTime[0] = time[i]
            minTime[1] = float64(i)
        }
    }
    ans := int(4+human[0]/minTime[0])
    if int(human[0])%int(minTime[0]) != 0{
        ans ++
    } 
    fmt.Println(ans)
}


Measured memory_bytes: 512
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

n = int(input())
for i in range(n):
    ch, rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank - 1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j + 1)


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

void printvec(vector<int> a, int n){
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl;
}

void bubbleSort(vector<int> a, int n){
    int flag = 1, count = 0;
    while(flag){
        flag = 0;
        for(int j=n-1; j>=1; j--){
            if(a[j]<a[j-1]){
                int tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
    }
    printvec(a, n);
    cout << count << endl;    
}

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

    bubbleSort(a, n);
}


Measured memory_bytes: 3160
class WarshallFloyd():
    """Warshall-Floyd Algorithm: 
       find the lengths of the shortest paths between all pairs of vertices
       used in GRL1C(AOJ), aoj0189
    """

    def __init__(self, V, E, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list
            start: start vertex
            INF: Infinity distance
        """
        self.V = V
        self.E = E
        self.warshall_floyd(INF)

    def warshall_floyd(self, INF):
        self.distance = [[INF] * self.V for _ in range(self.V)]
        for i in range(self.V): self.distance[i][i] = 0
        for fr in range(self.V):
            for to, cost in self.E[fr]:
                self.distance[fr][to] = cost
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    if self.distance[i][k] != INF and self.distance[k][j] != INF:
                        self.distance[i][j] = min(self.distance[i][j], self.distance[i][k] + self.distance[k][j])

    def hasNegativeCycle(self):
        for i in range(self.V):
            if self.distance[i][i] < 0:
                return True
        else:
            return False
                
while True:
    E = int(input())
    if E == 0: break
    V = 0
    edge = [[] for _ in range(10)]
    for _ in range(E):
        s, t, cost = map(int, input().split())
        V = max(s, t, V)
        edge[s].append((t, cost))
        edge[t].append((s, cost))
    allsp = WarshallFloyd(V+1, edge)
    ans = (10**9, 10**9)
    for i in range(V+1):
        ans = min(ans, (sum(allsp.distance[i]), i))
    print(*ans[::-1])

Measured memory_bytes: 6788
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void){
    
    int x,h;
    double sh;
    double sx;
    double ss;
    double s;
    
    
    while(cin>>x>>h,x!=0||h!=0){
        sh=h*h;
        sx=(double)(x/2.0)*(x/2.0);
        ss=sqrt(sh+sx);
        s=(double)(x)*(x)+4*ss*x*0.5;
    
        printf("%.6lf\n",s);
    }
    return(0);
}

Measured memory_bytes: 1192
n, k = map(int, input().split())

arr = [[False] * k for _ in range(n)] # person, snack

for i in range(k):
    m = int(input())
    for p in map(int, input().split()):
        arr[p-1][i] = True

total = 0
for i in range(n):
    if not any(arr[i]):
        total += 1

print(total)


Measured memory_bytes: 67820
def solve(xy):
    p = False
    if all([(x+y)%2==0 for x,y in xy]):
        p = True
    elif all([(x+y)%2==1 for x,y in xy]):
        pass
    else:
        print(-1)
        return
    m = [2**i for i  in range(30,-1,-1)]
    if p:
        m.append(1)
    anses = []
    for x,y in xy:
        usum, vsum = (0, 0)
        ans = []
        u = x+y
        v = x-y
        anses.append(ans)
        for d in m:
            if usum <= u:
                usum += d
                if vsum <= v:
                    vsum += d
                    ans.append('R')
                else:
                    vsum -= d
                    ans.append('U')
            else:
                usum -= d
                if vsum <= v:
                    vsum += d
                    ans.append('D')
                else:
                    vsum -= d
                    ans.append('L')
    print(len(m))
    print(" ".join([str(i) for i in m]))
    for a in anses:
        print("".join(a))


def main():
    n = int(input())
    xy = []
    for i in range(n):
        xy.append([int(i) for i in input().split()])
    solve(xy)

if __name__ == '__main__':
    main()

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

int GCD(int n, int m){
  if (n == 0) return m;
  return GCD(m % n, n);
}

int main()
{
  int n, m;

  while (cin >> n >> m){
    if (n > m){
      int c = n;
      n = m;
      m = c;
    }
    cout << GCD(n, m) << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		reader.readLine();
		int n = Integer.parseInt(reader.readLine());
		
		int[] y = new int[n];
		int[] x = new int[n];
		int[] sy = new int[n];
		int[] sx = new int[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer to = new StringTokenizer(reader.readLine());
			sx[i] = x[i] = Integer.parseInt(to.nextToken());
			sy[i] = y[i] = Integer.parseInt(to.nextToken());
		}
		Arrays.sort(x);
		Arrays.sort(y);
		int ax = 0;
		int ay = 0;
		long ans = Long.MAX_VALUE;
		int m = (n - 1) / 2;
		int nm = n/2;
		int[] xx = {x[m],x[nm]};
		int[] yy  ={y[m],y[nm]};
		for (int i = 0; i <= 1; i++) {
			for (int j = 0; j <= 1; j++) {
				long res = 0;
				long max = 0;
				for (int k = 0; k < n; k++) {
					long dis = Math.abs(sx[k] - xx[i]) + Math.abs(sy[k] - yy[j]);
					res += dis * 2;
					max = Math.max(max, dis);
				}
				res -= max;
				if (res < ans) {
					ans = res;
					ax = xx[i];
					ay = yy[j];
				}
			}
		}
		System.out.println(ans);
		System.out.println(ax + " " + ay);
	}
}

Measured memory_bytes: 45756
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
typedef long long int64;
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, a[N];
int64 ans;
int main()
{
    n = read(); 
    for(int i = 1; i <= n; ++i) a[i] = read();
    for(int i = 1; i <= n; ++i)
    {
        ans += a[i]>>1, a[i] &= 1;
        if(a[i]&&a[i+1]) --a[i], --a[i+1], ++ans;
    }
    printf("%lld\n", ans);
    return 0;
}   

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);

using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    return out;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

vector<vector<double> >dp;

vector<double> probability;

double solve(int index, int head)
{
    if(head<0)
        return 0.0;
    if(index<0)
        return head==0;
    if(dp[index][head]!=-1)
        return dp[index][head];

    dp[index][head]=(probability[index]*solve(index-1,head-1)+(1.0-probability[index])*solve(index-1,head));
    return dp[index][head];
}

int main()    
{
    #ifdef SANS
        freopen("ongoingin.txt","r",stdin);
        freopen("ongoingout.txt","w",stdout);
    #endif
    fast
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        probability.resize(n);
        cin>>probability;
        double ans=0;
        dp.resize(n,vector<double> (n+1,-1));
        for(int head=(n+1)/2; head<=n; head++)
        {
            ans+=solve(n-1,head);
        }
        cout<<setprecision(9)<<fixed;
        cout<<ans<<endl;
    }
    #ifdef SANS
        cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
    #endif
}

Measured memory_bytes: 74072
from collections import deque
S = input()
dq = deque()
for s in S:
    if not(dq):
        dq.append(s)
        continue
    if int(dq[-1]) + int(s) == 1:
        dq.pop()
    else:
        dq.append(s)
ans = len(S) - len(dq)
print(ans)

Measured memory_bytes: 4212
#include<stdio.h>
#include<string.h>
int main(void)
{
    char a[101];
	int i,h,n,m,flg;
	scanf("%s",&a);
	while(1){
	    n=0;
		m=0;
		flg=0;
	    h=strlen(a);
		if(h<=10) break;
	    for(i=0;i<h;i++){
		    if(n==10&&m==10) flg=1;
		    if(a[i+1]=='A'){
			    n++;
			}
			else if(a[i+1]=='B'){
			    m++;
			}
			else if(n==10&&i==h-1&&flg==0){
			    n++;
			}
			else if(m==10&&i==h-1&&flg==0){
			    m++;
			}
			else if(a[i]=='A'){
			    n++;
			}
			else if(a[i]=='B'){
			    m++;
			}
		}
		printf("%d %d\n",n,m);
		scanf("%s",&a);
	}
	return 0;
}

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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define INF 1e5
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(ll N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(ll x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(ll x, ll y)
  {                   // xとyの木を併合
    ll rx = root(x); //xの根をrx
    ll ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(ll x, ll y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    ll rx = root(x);
    ll ry = root(y);
    return rx == ry;
  }
};

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

  ll N, M;
  cin >> N >> M;
  UnionFind UF(N);

  loop(0, M, i)
  {
    ll A, B;
    cin >> A >> B;
    A--;
    B--;
    UF.unite(A, B);
  }

  map<ll, ll> exist;
  ll count = 0;

  ll mx = 0;
  loop(0, N, i) {
    ll r = UF.root(i);
    if (exist.find(r) == exist.end()) {
      exist[r] = 1;
    } else {
      exist[r] += 1;
    }
    mx = max(exist[r], mx);
  }
  print(mx);
}

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

int main() {
  int H,W;
  cin >>H>>W;
  vector<vector<char>> masu(110,vector<char>(110));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>masu.at(i).at(j);
    }
  }
  //vector<int> judgegyou(110);
  int gyousuu=0;
  bool dot=true;
  
  for(int i=0;i<H;i++){
    dot=true;
    for(int j=0;j<W;j++){
      if(masu.at(i).at(j)!='.')dot=false;
    }
    if(dot){
      for(int j=i;j<H;j++){
       for(int k=0;k<W;k++){
  masu.at(j).at(k)=masu.at(j+1).at(k);
       }   
      }
      gyousuu++;//ドットの行数
      i--;
    }
  }

  int retsusuu=0;
  
  for(int j=0;j<W;j++){
    dot=true;
    for(int i=0;i<H-gyousuu;i++){
      if(masu.at(i).at(j)!='.')dot=false;
    }
    if(dot){
      for(int i=j;i<W;i++){
       for(int k=0;k<H-gyousuu;k++){
  masu.at(k).at(i)=masu.at(k).at(i+1);
       }   
      }
      retsusuu++;//ドットの行数
      j--;
    }
  }

  
  
  
  for(int i=0;i<H-gyousuu;i++){
   for(int j=0;j<W-retsusuu;j++){
    cout<<masu.at(i).at(j);
     if(j==W-retsusuu-1)cout<<endl;
   }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

int main() {
    ll X;
    cin >> X;
    ll b = 100;
    int year = 0;
    while (1) {
        b += b / 100;
        year++;
        if (b >= X) {
            COUT(year);
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
int n,x,s,ans;
int main(void){
	while(scanf("%d",&n)*n){
		s=0;ans=-999999;
		for(;n>0;n--){
			scanf("%d",&x);
			s+=x;
			if(s>ans)ans=s;
			if(s<0)s=0;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

int main(){
    string S;
    cin >> S;
    map<char,int> M;
    rep(i,4){
        if(M.find(S[i])==M.end()){
            M[S[i]] = 1;
        }else{
            M[S[i]]++;
        }
    }
    rep(i,4){
        if(M[S[i]]==2)continue;
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main(){
	char inp;
    cin >> inp;
    if(inp == 'A') cout << "T\n";
    else if(inp == 'T') cout << "A\n";
    else if(inp == 'G') cout << "C\n";
    else  cout << "G\n";

	return 0;
}

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

int main (int argc, char **argv) {
  // 整数の入力
  int a;
  cin >> a;

  if(a%2==0){
    cout << a << endl;
  }else{
    cout << a*2 << endl;
  }


  return 0;
}

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

using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b) {
    return a.second<b.second;
}

int main() {
    int N;
    cin >> N;
    vector<pair<int, int> > A;
    
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        A.push_back(make_pair(i, a-1));
    }
    
    sort(A.begin(), A.end(), cmp);
    
    for(int i=0; i<N; i++) {
        cout << A[i].first+1 << " ";
    }
    cout << endl;

    return 0;
    
}

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

//組み合わせの数を数えるプログラム
int main(){
    int n, x, i, j, k, ways;
    
    while(1){
    	ways = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) break;

        i = 1;
        while(i <= n){
            j = 1;
            while(j < i){
                k = 1;
                while(k < j){
                    if (i + j + k == x) ways++;
                    k++;
                }
                j++;
            }
            i++;
        }
        cout << ways << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
using ll = long long;
using vl = vector<ll>;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i,n) cin >> x[i];
  ll ans = 0;
  rep(i,n-1) ans += min(a*(x[i+1]-x[i]),b);
  cout << ans << endl;
}

Measured memory_bytes: 4036
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        int result = 0;
        if(n != 100){
            result = (int)(Math.pow(100,d)) * n;
        }else{
            result = (int)(Math.pow(100,d)) * 101; 
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22612
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int[][] A = new int[3][];
        for(int i = 0; i < 3; i++){
            A[i] = in.ii();
        }
        int N = in.i();
        for(int i = 0; i < N; i++){
            int b = in.i();
            loop: for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(A[j][k] == b){
                        A[j][k] = 0;
                        break loop;
                    }
                }
            }
        }
        boolean flag = false;
        loop: for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(A[i][j] != 0){
                    continue loop;
                }
            }
            flag = true;
            break;
        }
        if(!flag){
            loop: for(int i = 0; i < 3; i++){
                for(int j = 0; j < 3; j++){
                    if(A[j][i] != 0){
                        continue loop;
                    }
                }
                flag = true;
                break;
            }
        }
        flag |= A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0 ||
        A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0;
        out.println(flag ? "Yes" : "No");
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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


int main() {
  int N, K;
  cin >> N >> K;
  vector<int> D(10, 0);
  rep(i, K){
    int x;
    cin >> x;
    D.at(x) = 1;
  }
  
  for(int i=N; i<=999999; ++i){
    int tmp=i;
    bool flg = true;
    while(tmp !=0){
    	if(D.at(tmp%10) == 1){
          flg = false;
          break;
        }
      tmp /=10;
    }
    if(flg){
      cout << i << endl;
      break;
      
    }
  }
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string N; cin >> N;
    ll f=0,X=0;
    ll a=1;
    for(int i=N.size()-1;i>=0;i--){
        ll t = (int)(N[i]-'0');
        f += t;
        X += a*t;
        a*=10;
    }
    cerr << X << "\t" << f << endl;
    if(X%f==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    long L;
    cin >> L;
    printf("%.10f\n", pow(L, 3)/27.0);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class ASecurity
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s[i] == s[i + 1])
                {
                    Console.WriteLine("Bad");
                    Console.ReadLine();
                    return;
                }
            }

            Console.WriteLine("Good");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        Arrays.fill(a, -1);
        boolean ans = true;
        for (int i = 0; i < m; i++) {
            int s = sc.nextInt()-1;
            int c = sc.nextInt();
            if(a[s] < 0) a[s] = c;
            else if(a[s] != c) {
                ans = false; break;
            }
        }
        if(ans){
            if(n == 1){
                System.out.println(a[0] < 0 ? 0 : a[0]);
            }else if(n == 2){
                if(a[0] == 0)System.out.println(-1);
                else {
                    int t = a[0] < 0 ? 1 : a[0];
                    t *= 10;
                    t += a[1] < 0 ? 0 : a[1];
                    System.out.println(t);
                }
            }else{
                if(a[0] == 0)System.out.println(-1);
                else{
                    int t = a[0] < 0 ? 100 : a[0]*100;
                    t += a[1] < 0 ? 0 : a[1]*10;
                    t += a[2] < 0 ? 0 : a[2];
                    System.out.println(t);
                }
            }
        }else System.out.println(-1);
        sc.close();

    }

}


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


int main() {

    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i % 26 # アルファベットは26コ
S = gets.chomp.chars # S 配列をキャラ型にして１文字ずつみる
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ".chars # alphabet 配列をキャラ型にして１文字ずつみる
ans = ""

S.each do |i|
  ans += alphabet[(alphabet.index(i) + N)]
end

puts ans

Measured memory_bytes: 19836
// in the name of Allah
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef long double ld ;

#define f fisrt
#define s second

const ll maxn = 3010 ;
const ll INF = 1e18 ;

ll n ;
ld dp[maxn][maxn] , p[maxn] , one = 1;

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

 cin >> n ;
 for(int i = 1 ; i <= n ; i ++)cin >> p[i] ;

 dp[1][0] = one-p[1] ;
 dp[1][1] = p[1] ;
 for(int i = 2 ; i <= n ; i ++){
    for(int j = 0 ; j <= i ; j ++){
        dp[i][j] = dp[i-1][j]*(one-p[i]) ;
        if(j > 0)dp[i][j] += dp[i-1][j-1]*(p[i]) ;
    }
 }
 ld ans = 0 ;
 for(int i = (n+1)/2 ; i <= n ; i ++)ans += dp[n][i] ;
 cout << fixed << setprecision(11) << ans ;
    return 0;
}


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

int H, W;
char m[51][51];

int solve() {
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(m[i][j] == '.') continue;
            // top
            if(i!=0) {
                if(m[i-1][j] == '#') continue;
            }
            // right
            if(j != W-1) {
                if(m[i][j+1] == '#') continue;
            }
            // bottom
            if(i!=H-1) {
                if(m[i+1][j] == '#') continue;
            }
            // left
            if(j!=0) {
                if(m[i][j-1] == '#') continue;
            }
            return 0;
        }
    }
    return 1;
}

int main () {
    memset(m, 0, sizeof(m));

    scanf("%d%d", &H, &W);
    for(int i=0; i<H; i++) {
        scanf("\n");
        for(int j=0; j<W; j++)
            scanf("%c", &m[i][j]);
    }
    
    printf("%s", solve()?"Yes":"No");
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n; cin >> n;
	if (n / 100 <= 12 && n / 100 >= 1) {
		if (n % 100 <= 12 && n % 100 >= 1) { cout << "AMBIGUOUS" << endl; }
		else { cout << "MMYY" << endl; }
	}
	else {
		if (n % 100 <= 12 && n % 100 >= 1) { cout << "YYMM" << endl; }
		else { cout << "NA" << endl; }
	}
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;

#define INF (1<<30)

typedef pair<int, int> pii;

vector<int> R;

vector<int> calc_rank(vector<pair<int, int>> status);

int calc_rank_all(vector<pii> S, vector<pii> C, vector<pii> P) {
    int N = S.size();
    vector<int> rank_S = calc_rank(S);
    vector<int> rank_C = calc_rank(C);
    vector<int> rank_P = calc_rank(P);

    vector<int> rank(S.size());
    vector<pii> score(S.size());
    for (int i = 0; i < N; i++) {
        score[i].first= R[rank_S[i]-1] + R[rank_C[i]-1] + R[rank_P[i]-1];
        score[i].second= i;
        // cerr << "score[" << i << "] = " << score[i].first << endl;
    }
    sort(score.begin(), score.end(), greater<pii>());

    rank[score[0].second] = 1;

    for (int i = 1; i < N; i++) {
        if (score[i].first == score[i-1].first)
            rank[score[i].second] = rank[score[i-1].second];
        else
            rank[score[i].second] = i + 1;

    }

    return rank[0];
}

vector<int> calc_rank(vector<pair<int, int>> status) {
    int N = status.size();

    sort(status.begin(), status.end(), greater<pii>());

    vector<int> rank(N);
    rank[status[0].second] = 1;

    for (int i = 1; i < N; i++) {
        if (status[i].first== status[i-1].first)
            rank[status[i].second] = rank[status[i-1].second];
        else
            rank[status[i].second] = i + 1;
    }

    // cerr << "--------------------" << endl;
    // for (int i=0; i<N; i++) {
    //     cerr << status[i].first << ", " << status[i].second << ", " << rank[i] << endl;
    // }

    return rank;
}


/*
vector<int> calc_rank(vector<pii> status)
{
    int N = status.size();
    sort(status.begin(), status.end(), greater<pii>());
}
*/

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

    vector<pair<int, int>> S(N), P(N), C(N);
    R.resize(N);

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

    for (int i = 0; i < N; i++) {
        cin >> S[i].first >> P[i].first >> C[i].first;
        S[i].second = i;
        P[i].second = i;
        C[i].second = i;
    }

    int ans = INF;
    for (int j = 1; j <= 100; j++) {
        // cerr << "------------------" << endl;
        // cerr << "j = " << j << endl;

        S[0].first += j;
        int rank = calc_rank_all(S, C, P);
        if (rank <= 8) {
            ans = min(ans, j);
        }

        S[0].first -= j;
    }

    for (int j = 1; j <= 100; j++) {
        P[0].first += j;
        int rank = calc_rank_all(S, C, P);
        if (rank <= 8) {
            ans = min(ans, j);
        }
        P[0].first-= j;
    }

    for (int j = 1; j <= 100; j++) {
        C[0].first += j;
        int rank = calc_rank_all(S, C, P);
        if (rank <= 8) {
            ans = min(ans, j);
        }
        C[0].first -= j;
    }

    if (ans == INF)
        cout << "Saiko" << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3088