akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b,c;
	cin >> a >> b >> c;
	if(abs(a-b)<abs(a-c)) cout << "A" << endl;
	else cout << "B" << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    multiset<int> mst;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        a *= -1;
        if (mst.upper_bound(a) == mst.end())
        {
            mst.insert(a);
        }
        else
        {
            auto itr = mst.upper_bound(a);
            mst.erase(itr);
            mst.insert(a);
        }
    }
    cout << mst.size() << endl;
}

Measured memory_bytes: 4992
from math import sqrt
from statistics import mean
while True:
    n = int(input())
    if n == 0:
        break
    else:
        L = list(map(int, input().split()))
        m = mean(L)
        temp = list(map(lambda x: (x-m)**2, L))
        SD = sqrt(sum(temp) / len(L))
        print(SD)


Measured memory_bytes: 7112
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

n,k = inp
a = inp
mem = na(n,nil)
ro = []
times = 0
pos = 1
rotete = 0
while true
  if(mem[pos-1])
    rotate = times - mem[pos-1]
    break
  end
  mem[pos-1] = times
  ro << pos
  pos = a[pos-1]
  times += 1
end
str = times - rotate
if(k < times)
  p ro[k]
else
  k -= times
  p ro[str+k%rotate]
end



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] inputData = Console.ReadLine().Split(' ');
            //Int32 inputData = Int32.Parse(Console.ReadLine());
            string inputData = Console.ReadLine();

            if (inputData.Contains("7"))
            {
                Console.WriteLine("Yes");

            } else
            { 
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 25884
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S; int K; cin >> S >> K;
  int idx=0;
  for(int i=0; i<S.size(); ++i) {
    if(S[i] != '1') break;
    ++idx;
  }
  if(K<=idx) cout << 1 << endl;
  else cout << S[idx] << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll N;
  cin>>N;
  vector<ll> A(N),cnt(N,0);
  rep(i,N){
  	cin>>A[i];
  	A[i]--;
    cnt[A[i]]++;
  }

  if(N==2){
  	cout<<"-1"<<endl;
  	return 0;
  }

  vector<bool> used(N,false);
  vector<ll> res(N);
  set<ll> st;
  rep(i,N){
    st.insert(i);
  }
  ll x=-1;
  rep(i,N-3){
    ll rest=N-i;
  	ll crt=-1;
  	ll Ax=-1;
  	if(x!=-1)Ax=A[x];

    ll mn=*st.begin();
    if(cnt[A[mn]]==rest-1&&!used[A[mn]]){
      crt=A[mn];
    }else{
      if(Ax==mn){
        auto it=st.begin();
        it++;
        crt=*it;
      }else{
        crt=mn;
      }
    }

  	used[crt]=true;
    st.erase(st.find(crt));
  	res[i]=crt;
  	x=crt;
    cnt[A[x]]--;
  }
  vector<ll> ps;
  rep(i,N){
  	if(used[i])continue;
  	ps.push_back(i);
  }
  do{
  	vector<ll> resb=res;
  	rep(i,3){
  		resb[N-3+i]=ps[i];
  	}
  	bool ok=true;
  	rep(i,N-1){
  		if(A[resb[i]]==resb[i+1])ok=false;
  	}
  	if(ok){
  		res=resb;
  		break;
  	}
  }while(next_permutation(all(ps)));

  rep(i,N)cout<<res[i]+1<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 7936
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BScoring {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int D;
        in>>D;
        vc<int> C(26);
        for(auto& c : C) in>>c;
        vvc<int> S(26, vc<int>(D));
        REP(j, D) REP(i, 26) in>>S[i][j];
        vc<int> T(D), last(26, -1);
        int score = 0;
        REP(i, D){
            in>>T[i];
            T[i]--;
            last[T[i]] = i;
            score += S[T[i]][i];
            REP(j, 26){
                score -= C[j] * (i-last[j]);
            }
            out<<score<<'\n';
        }
    }
};


int main() {
	BScoring solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
 
long long getS(long long u){
    long long res = 0;
    while(u){
        res += u%10;
        u /= 10;
    }
    return res;
}
 
int getBit(long long u){
    int res = 0;
    while(u){
        res++;
        u /= 10;
    }
    return res;
}
 
long long getNumber(int cur,int cnt){
    long long res = cur;
    for(int i = 0; i < cnt; i++) res = res*10+9;
    return res;
}
 
long long min(long long a,long long b){ return a>b?b:a; }
 
int main(){
    long long k;
    scanf("%lld",&k);
    for(int i = 1; i <= min(9,k); i++) printf("%d\n",i);
    int cur = 0, before = 9, cnt = 1;
    int bug = 0;
    k -= min(9,k);
    while(k!=0){
        cur++;
        printf("%d",cur);
        for(int i = 1; i <= cnt; i++) printf("9");
        printf("\n");
        k--;
        if(cur==before){
            cur = cur/10+1;
            cnt++;
            if(before!=99) before += 10;
            else{
                if(!bug) bug = 1;
                else before += 10;
            }
            if(k==0) break;
            printf("%d",cur);
            for(int i = 1; i <= cnt; i++) printf("9");
            printf("\n");
            k--;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int a[20],n;
inline long long read()
{
	long long x=0,y=1;char ch=getchar();
	while (ch>'9'||ch<'0'){
		if (ch=='-')y=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*y;
}

void dfs(int us,int len){
	if (len==n) {	for (int i=1;i<=len;i++)
	putchar('a'+a[i]-1);
	putchar('\n');return;
	}

	for (int i=1;i<=us;i++)
	a[len+1]=i,dfs(us,len+1);
	a[len+1]=us+1;
	dfs(us+1,len+1);
}
int main()
{
	n=read();
	a[1]=1;
	dfs(1,1);
}

Measured memory_bytes: 1536
#include<iostream>
int main() {
	int n, k;
	std::cin >> n >> k;
	int i = 1;
	for (int j = 0; j < n-1; j++) {
		i *= (k - 1);
	}
	i *= k;
	std::cout << i << std::endl;
	return 0;
}

Measured memory_bytes: 256
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
yes = 'Yes'
no = 'No'

S = input()

def main():
  checker = [odd, even]
  i=0
  for s in S:
    if not s in checker[i]:
      print(no)
      return
    i = 1 - i
  print(yes)
  return

main()


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

int main(void)
{
  int N,M,i,sum=0,res=0,A[10000];
  
  scanf("%d %d\n",&N,&M);
  
  for(i=0;i<M;i++)
  {
    scanf("%d",&A[i]);
    sum+=A[i];
  }

  res=N-sum;
  
  if(res<0)
  {
    res=-1;
  }
    
  printf("%d",res);
  return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
int main()
{
	long long a,b,n,x,sum,nub=0,r;
	scanf("%lld",&n);
	r=sqrt(n);
	for(int i=2;i<=r;i++)
	{
		if(n%i==0)
		{
			b=i;
			nub++;
		}
	}
	if(nub==0)
	{
		b=1;
	}
	
	a=n/b;
	if(a>b)
	{
		sum=a;
	}else
	{
		sum=b;
	}
	for(int i=1;i<=sum;i++)
	{
		sum=sum/10;
		if(sum<10)
		{
			sum=i+1;
			break;
		}
	}
	if(n==1)
	{
		printf("1");
	}else printf("%lld",sum);
}


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

int main(){
	string tmp;
	cin>>tmp;
	
	vector<char> w;
	int n=tmp.size();
	REP(i,n) w.push_back(tmp[i]);
	
	sort(w.begin(),w.end());
	
	bool jud=true;
	char word=w[0];
	int cnt=1;
	for(int i=1;i<n;++i){
		if(w[i]==w[i-1]){
			cnt++;
		}else{
			if(cnt%2!=0){
				jud=false;
				goto Exit;
			}
			
			
			word=w[i];
			cnt=1;
		}
	}
	if(cnt%2!=0) jud=false;
	
	Exit:
	if(jud) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N; // 人
    cin >> N;
    map<int, int> mp; //出席番号, きた順
    rep(i, N) {
        int v;
        cin >> v;
        mp[v] = i;
    }

    for(auto x : mp) {
        cout << x.second << "\n";
    }
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int N; cin >> N;
  vi P(N); rep(i,N) cin >> P[i];
  int count = 0;
  int minA = P[0];
  rep(i,N){
    if (P[i] <= minA) {count++; minA = P[i];}
  } 
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
long mod=998244353;
string s;
int N;
main()
{
	cin>>N>>s;
	queue<int>id[3];
	for(int i=0;i<s.size();i++)
	{
		id[s[i]=='R'?0:s[i]=='G'?1:2].push(i);
	}
	vector<pair<int,int> >L[3],R[3];
	for(int i=0;i<N;i++)
	{
		int a=id[0].front(),b=id[1].front(),c=id[2].front();
		id[0].pop();id[1].pop();id[2].pop();
		if(b<a^c<a)
		{
			if(b<c)
			{
				L[1].push_back(make_pair(b,a));
				R[2].push_back(make_pair(c,a));
			}
			else
			{
				L[2].push_back(make_pair(c,a));
				R[1].push_back(make_pair(b,a));
			}
		}
		else if(a<b^c<b)
		{
			if(a<c)
			{
				L[0].push_back(make_pair(a,b));
				R[2].push_back(make_pair(c,b));
			}
			else
			{
				L[2].push_back(make_pair(c,b));
				R[0].push_back(make_pair(a,b));
			}
		}
		else
		{
			if(a<b)
			{
				L[0].push_back(make_pair(a,c));
				R[1].push_back(make_pair(b,c));
			}
			else
			{
				L[1].push_back(make_pair(b,c));
				R[0].push_back(make_pair(a,c));
			}
		}
	}
	long ans=1;
	for(int i=0;i<3;i++)
	{
		sort(L[i].begin(),L[i].end());
		priority_queue<int>P;
		for(pair<int,int>p:L[i])
		{
			while(!P.empty()&&-P.top()<p.first)P.pop();
			P.push(-p.second);
			ans=ans*P.size()%mod;
		}
		sort(R[i].begin(),R[i].end());
		reverse(R[i].begin(),R[i].end());
		priority_queue<int>Q;
		for(pair<int,int>p:R[i])
		{
			while(!Q.empty()&&Q.top()>p.first)Q.pop();
			Q.push(p.second);
			ans=ans*Q.size()%mod;
		}
	}
	for(int i=1;i<=N;i++)ans=ans*i%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
#define MOD 1000000007
using namespace std;

signed main() {
    int n, m;
    cin >> n >> m;

    if (abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for (int i = n; i > 0; i--) {
        ans *= i;
        ans %= MOD;
    }
    
    for (int i = m; i > 0; i--) {
        ans *= i;
        ans %= MOD;
    }

    if (n == m) {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* In the name of Allah */
#include <bits/stdc++.h>
using namespace std;
 
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define Size(x) ((int)(x).size())
#define Precision(i) cout << fixed << setprecision(i)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int MAX_N = 1e5 + 10;
ll a[MAX_N], mn[MAX_N], mx[MAX_N];
 
ll f(ll a, ll b) {
	ll ans = a / b;
	if(a % b)
		ans++;
 
	return ans;
}
 
int main() {
	ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
	int k;
	cin >> k;
	for(int i = 0; i < k; i++)
		cin >> a[i];

	if(a[k - 1] != 2)
		return cout << "-1\n", 0;
 
	mn[k - 1] = 1, mx[k - 1] = 1;
	for(int i = k - 2; i >= 0; i--) {
		mn[i] = f(a[i + 1] * mn[i + 1], a[i]);
		mx[i] = (a[i + 1] * mx[i + 1] + a[i + 1] - 1) / a[i];
 
		if(mn[i] > mx[i] || (mn[i] * a[i]) / a[i + 1] > mx[i + 1])
			return cout << "-1\n", 0;
	}
 
	cout << mn[0] * a[0] << ' ' << mx[0] * a[0] + a[0] - 1 << endl;
 
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int bubble_sort(vi a)
{
	int res = 0;
	while (true)
	{
		bool update = false;
		rep(i, sz(a)-1)
		{
			if (a[i] > a[i + 1])
			{
				swap(a[i], a[i + 1]);
				update = true;
				res++;
			}
		}
		if (!update)break;
	}
	return res;
}

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

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	int mi = a[0];
	int ans = 0;
	rep(i, n)
	{
		if (mi >= a[i])ans++;
		chmin(mi, a[i]);
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cstring>

#define maxn 36

using namespace std;

char map[6][3][3], tmp[maxn];
int hole[6][4], hpair[6][4];

void clean()
{
    memset(map, 0, sizeof(map));
    memset(hole, 0, sizeof(hole));
    memset(hpair, 0, sizeof(hpair));
}

void read()
{
    char tmp2[maxn];

    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 3; j++){
            if(i == 0 && j == 0)
                strcpy(tmp2, tmp);
            else scanf("%s", tmp2);
            for(int k = 0; k < 3; k++)
                map[i][j][k] = tmp2[k];
        }
    }
}

void signp()
{
    hpair[0][0] = hole[0][0] & hole[2][0];//1-3-0
    hpair[0][1] = hole[0][1] & hole[2][3];//1-3-1
    hpair[0][2] = hole[0][2] & hole[2][2];//1-3-2
    hpair[0][3] = hole[0][3] & hole[2][1];//1-3-3

    hpair[1][0] = hole[1][0] & hole[3][0];
    hpair[1][1] = hole[1][1] & hole[3][3];
    hpair[1][2] = hole[1][2] & hole[3][2];
    hpair[1][3] = hole[1][3] & hole[3][1];

    hpair[4][0] = hole[4][0] & hole[5][2];
    hpair[4][1] = hole[4][1] & hole[5][1];
    hpair[4][2] = hole[4][2] & hole[5][0];
    hpair[4][3] = hole[4][3] & hole[5][3];
}

void sign()
{
    for(int i = 0; i < 6; i++)
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(map[i][j][k] == '*'){
                    if(j == 0) hole[i][0] = 1;//up
                    if(k == 2) hole[i][1] = 1;//right
                    if(j == 2) hole[i][2] = 1;//down
                    if(k == 0) hole[i][3] = 1;
                }

    signp();
}

int chk()
{
    if(hpair[0][2]) return 0;
    if(hpair[0][1]) return 1;
    if(hpair[0][3]) return 1;
    if(hpair[4][0]) return 1;
    if(hpair[4][2]) return 1;
    if(hpair[4][1]) return 2;
    if(hpair[4][3]) return 2;
    if(hpair[0][0]) return 2;
    if(hpair[1][1]) return 2;
    if(hpair[1][3]) return 2;
    if(hpair[1][0]) return 3;
    if(hpair[1][2]) return 3;

    return -1;
}

void solve()
{
    clean();
    read();
    sign();
    cout << chk() << endl;
}

int main(void)
{
    while(scanf("%s", tmp), tmp[0] !='#')
        solve();

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main() {
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		scanf("%d %d %d", &c[i][0], &c[i][1], &c[i][2]);
	}

	int flag = 0;
	for (int i = 0; i < 2; i++) {
		int tmp = c[0][i+1] - c[0][i];
		for (int j = 1; j < 3; j++) {
			if (tmp != (c[j][i+1] - c[j][i])) flag = 1;
		}
		if (flag == 1) break;
	}

	if (flag == 1) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
  ll N, M;
  cin >> N >> M;
  
  if(N == 1 && M == 1){cout << 1 << endl; return 0;}
  else if(N == 1 || M == 1){cout << N * M - 2 << endl; return 0;}
  else if(N == 2 || M == 2){cout << 0 << endl; return 0;}
  else{
    cout << (N-2)*(M-2) << endl;
  }
  return 0;
}

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

int main() {
  int n,k,sum,x[105];
  cin>>n>>k;
  for(int i=0; i<n; i++) cin>>x[i];
  for(int i=0; i<n; i++) {
    sum += 2 * min(x[i],k-x[i]);
  }
  cout<<sum;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);
        int d = int.Parse(s[3]);
        if (Math.Abs(b - a) <= d && Math.Abs(c - b) <= d || Math.Abs(c - a) <= d)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


Measured memory_bytes: 11220
#include<stdio.h>
int main(){
	char a[1000],b[1000];
	int n,i=0;
	scanf("%d",&n);
	scanf("%s%s",a,b);
	for(i=0;i<n;i++){
		printf("%c%c",a[i],b[i]);
	}
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        double k;
        string s;
        cin >> k >> s;
        if (s == "JPY") {
            sum += k;
        } else {
            sum += k * 380000;
        }
    }
    printf("%.6lf\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
ll arr[55][55],a[55][55],temp[55][55];
int n;

void multiply(ll b[][55],ll c[][55]){
	for(int i = 0;i<n;i++){
		for(int j = 0;j<n;j++){
			ll ans = 0;
			for(int k = 0;k<n;k++){
				ans = (ans + (b[i][k]*c[k][j])%mod)%mod;
			}
			a[i][j] = ans;
		}
	}
	
	for(int i = 0;i<n;i++)
		for(int j = 0;j<n;j++)
			arr[i][j] = a[i][j];
}

void power(ll k){
	//cout<<k<<endl;
	if(k<=1)
		return ;
		
	power(k/2);
	multiply(arr,arr);
	if(k%2!=0)
		multiply(arr,temp);
}

int main(){
	boost;
	cin>>n;
	ll k;
	cin>>k;
	
	for(int i = 0;i<n;i++){
		for(int j = 0;j<n;j++){
			cin>>arr[i][j];
			temp[i][j] = arr[i][j];
		}
	}
	
	power(k);
	ll t = 0;
	for(int i = 0;i<n;i++){
		ll ans = 0;
		for(int j = 0;j<n;j++){
			ans = (ans + arr[j][i])%mod;
		}
		t = (t + ans)%mod;
	}
	
	cout<<t;
	return 0;
}



Measured memory_bytes: 3672
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
a = list(myinput())

l = [0]*n
for i in range(n):
    if i==0:
        l[i] = a[i]
    else:
        l[i] = gcd(l[i-1],a[i])
# print(l)

r = [0]*n
for i in reversed(range(n)):
    if i==(n-1):
        r[i] = a[i]
    else:
        r[i] = gcd(r[i+1],a[i])
# print(r)

m = [0]*n
for i in range(n):
    if i==0:
        m[i] = r[1]
    elif i==(n-1):
        m[i] = l[n-2]
    else:
        m[i] = gcd(l[i-1],r[i+1])
# print(m)

ans = max(m)
print(ans)

Measured memory_bytes: 91532
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// dijkstra
// depend:edge
vector<long long int> dijkstra(vector<vector<edge>>& g, int start) {
    using lint = long long int;
    vector<lint> res(g.size(), LLONG_MAX);
    res[start] = 0;
    // first:距離、second:行き先
    priority_queue<pair<lint, lint>, vector<pair<lint, lint>>,
                   greater<pair<lint, lint>>>
        pq;
    pq.push({0, start});
    while (!pq.empty()) {
        lint dist = pq.top().first, now = pq.top().second;
        pq.pop();
        if (res[now] < dist) continue;
        for (int i = 0; i < (int)g[now].size(); i++) {
            edge e = g[now][i];
            if (res[e.to] > res[now] + e.cost) {
                res[e.to] = res[now] + e.cost;
                pq.push(make_pair(res[e.to], e.to));
            }
        }
    }
    return res;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<edge>> g_yen(n), g_snuuk(n);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        g_yen[u].push_back(edge(v, a));
        g_yen[v].push_back(edge(u, a));
        g_snuuk[u].push_back(edge(v, b));
        g_snuuk[v].push_back(edge(u, b));
    }
    vector<lint> d_s = dijkstra(g_yen, s), d_t = dijkstra(g_snuuk, t);
    // loss[i]:[i,n)の街で両替する時の使用金額の最小値
    vector<lint> loss(n + 1);
    loss[n] = LLONG_MAX;
    for (int i = n - 1; i >= 0; i--) {
        loss[i] = min(loss[i + 1], d_s[i] + d_t[i]);
    }
    for (int i = 0; i < n; i++) {
        cout << (lint)1e+15 - loss[i] << endl;
    }
}

Measured memory_bytes: 19012
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				ans+=gcd(gcd(i,j),k); 
			}
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N, M;
    cin >> N >> M;
    u32 sum = 0;
    for (int i = 0; i < M; i++) {
        u32 a;
        cin >> a;
        sum += a;
    }
    if (sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

// MOD確認

int main(){
    /*string S,T;
    cin >> S >> T;
    if(T.substr(0,S.size()) == S) cout << "Yes" << endl;
    else cout << "No" << endl;*/
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(A >= K){
       cout << K << endl;
    }else if(A + B >= K){
        cout << A << endl;
    }else{
        cout << A - (K - (A+B)) << endl;
    }
} 


Measured memory_bytes: 3624
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const llint mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
int main(void){
	int a,b;cin>>a>>b;
	string str;cin>>str;
	for(int i=0;i<str.size();i++){
		if((i==a)!=(str[i]=='-')){cout<<"No"<<endl;RE;}
	}
	cout<<"Yes"<<endl;RE;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split(' ');
	var a = parseInt(input[0]);
	var b = parseInt(input[1]);
	var ret = a*b+a*(a-1)/2;
	if(b*(a+b-1) <= 0)console.log('%d', ret);
	else if(Math.abs(b) < Math.abs(a+b-1))console.log('%d', ret-b);
	else console.log('%d', ret-(a+b-1));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000
struct Edge{
	int next,to;
}edge[maxn*2+5];
int fi[maxn+5],se,pre[maxn+5],depth[maxn+5];
int vis[maxn+5],fl;
inline void add_edge(int u,int v){
	edge[++se].next=fi[u],edge[se].to=v,fi[u]=se;
}
int q[maxn+5],s,t;
void Put(int x){
	int ans=0,x1=x;fl=1;
	do{x1=pre[x1],ans++;}while(x1!=x);
	printf("%d\n",ans);
	x1=x;
	do{printf("%d\n",x),x=pre[x];}while(x!=x1);
}
int up(int x,int k){
	if(k<=0)return x;
	while(k--)x=pre[x];
	return x;
}
void bfs(int v1){
	s=t=0,q[t++]=v1,vis[v1]=v1,depth[v1]=1;
	while(s<t){
		int x=q[s++];
		for(int i=fi[x];i;i=edge[i].next){
			int v=edge[i].to;
			if(!vis[v])vis[v]=v1,q[t++]=v,pre[v]=x,depth[v]=depth[x]+1;
			else if(vis[v]==v1){
				if(up(x,depth[x]-depth[v])!=v)continue;
				pre[v]=x;
				if(depth[v]>depth[fl])fl=v;
			}
		}
		if(fl){Put(fl);return;}
	}
}
int main(){
	int n,m,u,v;scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)scanf("%d%d",&u,&v),add_edge(u,v);
	for(int s=1;s<=n;s++){
		if(!vis[s])bfs(s);
		if(fl)break;
	}
	if(!fl){puts("-1");return 0;}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] p=new int[n];
		int[] q=new int[n+1];
		TreeMap<Integer,Integer> map=new TreeMap<>();
		long ans=0;
		for(int i=0; i<n; i++){
			p[i]=sc.nextInt();
			q[p[i]]=i;
		}
		map.put(n,n+1);
		map.put(-1,n+1);
		map.put(q[n],n);
		for(int i=n-1; i>0; i--){
			map.put(q[i],i);
			long h1=map.higherKey(q[i]);
			long h2=h1;
			if(h1!=n){
				h2=map.higherKey((int)h1);
			}
			long l1=map.lowerKey(q[i]);
			long l2=l1;
			if(l1!=-1){
				l2=map.lowerKey((int)l1);
			}
			ans+=i*((h2-h1)*(q[i]-l1)+(h1-q[i])*(l1-l2));
		}
		System.out.println(ans);
	}
}


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

int main() {
  long K, num;
  int N;
  cin >> K >> N;
  vector<long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  num = A.at(0) + K - A.at(N-1);
  for (int i = 0; i < N-1; i++) {
    if (A.at(i+1) - A.at(i) > num) {
      num = A.at(i+1) - A.at(i);
    }
  }
  cout << K - num;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	int k; cin >> k;
	string s; cin >> s;
	if((int) s.size() <= k) cout << s;
	else{
		cout << s.substr(0, k) << "..." ;
	}
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define MAX 25
struct Node{
    int parent;
    int left;
    int right;
};
Node N[MAX];
int root;

void printPreorder(int node){
    cout << node;
    
    if(N[node].left != -1){
        cout << " ";
        printPreorder(N[node].left);
    }
    if(N[node].right != -1){
        cout << " ";
        printPreorder(N[node].right);
    }
}

void printInorder(int node){
    if(N[node].left != -1){
        printInorder(N[node].left);
        cout << " ";
    }
    cout << node;
    if(N[node].right != -1){
        cout << " ";
        printInorder(N[node].right);
    }
}

void printPostorder(int node){
    if(N[node].left != -1){
        printPostorder(N[node].left);
        cout << " ";
    }
    if(N[node].right != -1){
        printPostorder(N[node].right);
        cout << " ";
    }
    cout << node;
}

int main(void){
    int n, id, l, r;
    
    cin >> n;
    for(int i = 0; i < n; i++) N[i].parent = -1;
    
    for(int i = 0; i < n; i++){
        cin >> id >> l >> r;
        N[id].left = l;
        N[id].right = r;
        if(l != -1) N[l].parent = id;
        if(r != -1) N[r].parent = id;
    }
    
    for(int i = 0; i < n; i++){
        if(N[i].parent == -1){
            root = i;
            break;
        }
    }
    
    cout << "Preorder" << endl;
    cout << " ";
    printPreorder(root);
    cout << endl;
    
    cout << "Inorder" << endl;
    cout << " ";
    printInorder(root);
    cout << endl;
    
    cout << "Postorder" << endl;
    cout << " ";
    printPostorder(root);
    cout << endl;
}



Measured memory_bytes: 3084
# coding: utf-8
import queue

class Dinic:
    """Implementation of Dinic's Alogorithm"""

    def __init__(self, v, inf = 1000000007):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]

    def add_edge(self, from_, to, cap):
        # to: 行き先, cap: 容量, rev: 反対側の辺
        self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
        self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})

    # sからの最短距離をbfsで計算
    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0;
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])

    # 増加バスをdfsで探す
    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d

        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            # bfsで到達不可
            if self.level[t] < 0 : return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s,t, self.inf)

if __name__ =="__main__":
    H,W=map(int,input().split())
    a=[list(input()) for i in range(H)]
    Dn=Dinic(2+H+W)
    INF=10**15
    #0,1~H,H+1~H+1+W.H+W+1
    #0 1+range(H),H+1+range(W),H+W+1
    s=(-1,-1)
    t=(-1,-1)
    for i in range(H):
        for j in range(W):
            if a[i][j]!=".":
                Dn.add_edge(i+1,H+1+j,1)
                Dn.add_edge(H+1+j,i+1,1)
            if a[i][j]=="S":
                Dn.add_edge(0,i+1,INF)
                Dn.add_edge(0,H+1+j,INF)
                s=(i,j)
            if a[i][j]=="T":
                Dn.add_edge(i+1,H+W+1,INF)
                Dn.add_edge(H+1+j,H+W+1,INF)
                t=(i,j)
    if s[0]==t[0] or s[1]==t[1]:
        print(-1)
    else:
        ans=Dn.max_flow(0,1+H+W)
        print(ans)


Measured memory_bytes: 16368
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        t: usize,
    }

    if n % x == 0 {
        println!("{}", (n / x) * t);
    } else {
        println!("{}", ((n / x) + 1) * t);
    }
}


Measured memory_bytes: 2172
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;



int main(){
  char JI[1000000];
  int i,JOIcou,IOIcou,k;
 

  i=0;
  JOIcou=0;
  IOIcou=0;
  
  
  while(scanf("%c",&JI[i])!=EOF)
    {
      
      if(JI[i]=='\n')
	{
	  
	
	  cout << JOIcou << endl;
	  cout << IOIcou << endl;
	   i=0;
  JOIcou=0;
  IOIcou=0;
  
	}	
      if(i==0){}
      else if(i==1){}
      else{
	
	if(JI[i]=='I' &&JI[i-1]=='O' && JI[i-2]=='J')JOIcou++;
	if(JI[i]=='I' &&JI[i-1]=='O' &&JI[i-2]=='I')IOIcou++; 
      }
      i++;
    }  
}

Measured memory_bytes: 0
import math
a,b,x = map(int,input().split())
if x >= ((a**2)*b)//2:
    print(math.degrees(math.atan(2*((((a**2)*b)/2)-(x-((a**2)*b)/2))/(a**3))))
else:
    print(90-math.degrees(math.atan((2*x)/(a*(b**2)))))


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <bitset>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int M, N;
bitset<128> question[11];
int memo[1<<11][1<<11];
int dfs(int used, int mask){
  int& res = memo[used][mask];
  if(res != -1) return res;
  bitset<128> cur;
  REP(i, N) cur.set(i, true);
  REP(i, M) if(used & (1<<i)){
    if(mask & (1<<i)){
      cur &= question[i];
    }else{
      cur &= (~question[i]);
    }
  }
  if(cur.count() <= 1){
    res = 0;
  }else{
    res = INF;
    REP(i, M) if(!(used & (1<<i))){
      res = min(res, 1 + max(dfs(used | (1<<i), mask), dfs(used | (1<<i), mask | (1<<i))));
    }
  }
  //printf("dfs(%d, %d) return %d\n", used, mask, res);
  assert(res < INF);
  return res;
}
int main(){
  while(cin>>M>>N && M){
    memset(memo, -1, sizeof(memo));
    REP(i, M) question[i] = bitset<128>();
    REP(i, N){
      string s; cin>>s;
      REP(j, M)if(s[j] == '1'){
        question[j].set(i, true);
      }
    }
    cout<<dfs(0, 0)<<endl;
  }
  return 0;
}


Measured memory_bytes: 19440
def main():
  num = list(map(int,input().split()))
  if (num[0] in [1,3,5,7,8,10,12] and num[1] in [1,3,5,7,8,10,12] ) or (num[0] in [4,6,9,11] and num[1] in [4,6,9,11] ) or (num[0] ==2 and num[1] ==2):
    print('Yes')
  else:
    print('No')
      
main()

Measured memory_bytes: 3060
while True:
 h,w=map(int,input().split())
 if h==0 and w==0:
  break
 for i in range(h):
  for j in range(w):
   if (i+j)%2==0:
     print("#",end="")
   else:
     print(".",end="")
  print()
 print()


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    lint a, b, k; cin>>a>>b>>k;
    for(int x = a; x <= a + k - 1; x++){
        if(x > b) break;
        out(x);
    }
    for(int x = b - k + 1; x <= b; x++){
        if(x <= a + k - 1) continue;
        out(x);
    }
}

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

#define lint long long
#define P pair<int, int>


int main(){
    string S;
    
    cin >> S;
    
    int N = S.length();
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        if(S[i] == '0'){
            cnt++;
        }
    }
    
    cnt = min(cnt, N - cnt);
    
    cout << 2 * cnt << endl;
}

Measured memory_bytes: 512
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;


static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];


void floyd() {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (d[i][k] == INFTY)continue;
            for (int j = 0; j < n; j++) {
                if (d[k][j] == INFTY)continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
int main()
{
    int e, u, v, c;
    cin >> n >> e;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = { (i == j) ? 0 : INFTY };
        }
    }

    for (int i = 0; i < e; i++) {
        cin >> u >> v >> c;
        d[u][v] = c;
    }
    floyd();

    bool negative = false;
    for (int i = 0; i < n; i++)if (d[i][i] < 0)negative = true;
    if (negative) {
        cout << "NEGATIVE CYCLE" << endl;
    }
    else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j)cout << " ";
                if (d[i][j] == INFTY)cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}




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

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

const long long INF = 1LL << 40;

int main() {
  int num;
  
  cin >> num;
  
  long long dp[num];
  long long h[num];
  
  for(int i = 0; i < num; i++) dp[i] = INF;

  for(int i = 0; i < num; i++){
    cin >> h[i];
  }
  
  dp[0] = 0;
  for(int i = 1; i < num; i++){
    ChkMin(dp[i], abs(h[i] - h[i-1]) + dp[i-1]);
    if(i > 1) ChkMin(dp[i], abs(h[i] - h[i-2]) + dp[i-2]);
  }
  
  cout << dp[num-1];
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static String S;


    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        S = sc.next();

        System.out.println( solve() );
    }

    private static String solve() {
        int L = 0;
        int R = 0;

        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);

            if( c == '(' ) {
                R++;
            } else {
                if( R == 0 ) {
                    L++;
                } else {
                    R--;
                }
            }
        }
        return times('(', L) + S + times(')', R);
    }

    static String times(char c, int n) {
        StringBuilder b = new StringBuilder();
        for (int i = 0; i < n; i++) {
            b.append(c);
        }
        return b.toString();
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 20948
#include <string>
#include <iostream>

using namespace std;

int main(){
  string a;
  string b;
  int n=0;

  cin >> a;
  cin >>b;
  for(int i = 0; i < a.size(); ++i){
    if(a[i]==b[i])continue;
    n++;
  }
  cout << n <<endl;
  return 0;
}

Measured memory_bytes: 3828