akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<int>> d(C, vector<int>(C));
  for (int i = 0; i < C; ++i)
    for (int j = 0; j < C; ++j)
      cin >> d[i][j];

  vector<vector<int>> dp(3, vector<int>(C, 0));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      int c;
      cin >> c;
      --c;
      for (int k = 0; k < C; ++k)
        dp[(i + j) % 3][k] += d[c][k];
    }
  }

  int ret = dp[0][0] + dp[1][1] + dp[2][2];
  for (int i = 0; i < C; ++i) {
    for (int j = 0; j < C; ++j) {
      if (i == j) continue;
      for (int k = 0; k < C; ++k) {
        if (i == k || j == k) continue;
        int sum = dp[0][i] + dp[1][j] + dp[2][k];
        ret = min(ret, sum);
      }
    }
  }
  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    use std::collections::HashMap;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: i64 = scan(tokens);
    let x: i64 = scan(tokens);
    let d: i64 = scan(tokens);
    if d == 0 {
        if x == 0 {
            println!("{}", 1);
        } else {
            println!("{}", n + 1);
        }
        return;
    }
    let (x, d) = if d > 0 { (x, d) } else { (x + (n - 1) * d, -d) };
    let mut intervals = HashMap::new();
    for k in 0..n + 1 {
        let mut m = k * x % d;
        if m < 0 {
            m += d;
        }
        let a = (k * x - m) / d + k * (0 + (k - 1)) / 2;
        let b = (k * x - m) / d + k * ((n - k) + (n - 1)) / 2;
        intervals.entry(m).or_insert_with(Vec::new).push((a, b + 1));
    }
    let mut ans = 0;
    for v in intervals.values_mut() {
        v.sort();
        let mut x = std::i64::MIN;
        let mut y = std::i64::MIN;
        for &(a, b) in v.iter() {
            if y < a {
                ans += y - x;
                x = a;
                y = b;
            } else {
                y = std::cmp::max(y, b);
            }
        }
        ans += y - x;
    }
    println!("{}", ans);
}


Measured memory_bytes: 26816
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
int a,b,c,n;
int t[10000];
int x[10000];
int y[10000];
int z[10000];
int r[10000];

int main(){

while(true){
rep(i,2000)t[i]=x[i]=y[i]=z[i]=r[i]=0;

cin>>a>>b>>c;
if(a+b+c==0)break;
cin>>n;

for(int i=1;i<=a+b+c;i++)t[i]=2;

rep(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];

rep(xx,n){
for(int i=0;i<n;i++){
	if(r[i]==1){
		t[x[i]]=1;
		t[y[i]]=1;
		t[z[i]]=1;
		
	}
	else{
		int cnt=0;
			if(t[x[i]]==1&&t[y[i]]==1)t[z[i]]=0;
			if(t[y[i]]==1&&t[z[i]]==1)t[x[i]]=0;
			if(t[z[i]]==1&&t[x[i]]==1)t[y[i]]=0;
	}
}
}
	for(int i=1;i<=a+b+c;i++)cout<<t[i]<<endl;

}
	return 0;
}


Measured memory_bytes: 3088
import sys
a = [0]*3
for i in range(3):
    a[i] = list(map(int,input().split()))
n = int(input())
b = [0 for _ in range(n)]
for k in range(n):
    b[k] = int(input())
flag = [[0 for u in range(3)]for r in range(3)]

for j in range(3):
    for l in range(3):
        for v in range(n):
            if(a[j][l] == b[v]):
                flag[j][l] = 1
                break

for h in range(3):
    if(sum(flag[h]) == 3):
      print("Yes")
      sys.exit()

if(flag[0][0] + flag[1][1] + flag[2][2] == 3 or flag[0][2] + flag[1][1] + flag[2][0] == 3):
    print("Yes")
    sys.exit()

if(flag[0][0] + flag[1][0] + flag[2][0] == 3 or flag[0][1] + flag[1][1] + flag[2][1] == 3 or flag[0][2] + flag[1][2] + flag[2][2] == 3):
    print("Yes")
    sys.exit()
print("No")

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

string S;
int main() {
    while (cin >> S) {
        bool ok = false;
        for (auto c : S) if (c == '7') ok = true;
        cout << (ok ? "Yes":"No") << endl;
    }
}

















Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>

using namespace std;

int n;
int m;
vector<int> ve;
multiset<int> se;

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d", &n);
    m = (1 << n);
    for(int i = 0; i < m; i++)
    {
        int t;
        scanf("%d", &t);
        se.insert(t);
    }
    auto it = se.end();
    it--;
    ve.push_back(*it);
    se.erase(it);
    for(int i = 1; i < m; i += i)
    {
        for(int j = ve.size() - 1; j >= 0; j--)
        {
            auto it2 = se.lower_bound(ve[j]);
            if(it2 == se.end() || *it2 >= ve[j] && it2 != se.begin()) it2--;
            else if(*it2 >= ve[j])
            {
                printf("No");
                return 0;
            }
            ve.push_back(*it2);
            se.erase(it2);
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 13692
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a;
        int i = 1;
        while(true){
            a = sc.nextInt();
            if(a == 0){
                break;
            }else{
                System.out.println("Case " + i +": " + a);
                i = i + 1;
            }
        }
        
    }
}


Measured memory_bytes: 41228
#include<cstdio>

int min(int a,int b){ return a>b?b:a; }

int main(){
    int n;
    scanf("%d",&n);
    int reach = 0;
    int ans = n+1;
    for(int i = 1; i <= n; i++){
        int u;
        scanf("%d",&u);
        if(u<=reach+1){
            ans = min(ans,(n-i)+(i-u));
        }
        if(u==reach+1) reach++;
    }
    if(ans<=n-1) printf("%d\n",ans);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 128
parseLine() = parse.(Int,split(readline()))

function solve()
    N, K = parseLine()
    A = parseLine()
    ans = 1
    while K > 0
        K&1==1 && (ans = A[ans])
        next = Vector{Int}(undef, N)
        for i in 1:N
            next[i] = A[A[i]]
        end
        A = next
        K >>= 1
    end
    println(ans)
end

solve()

Measured memory_bytes: 242668
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,d;
scanf("%d%d",&n,&d);
int ans=0;
for(int i=1;i<=n;i++){
    double x,y;
    scanf("%lf%lf",&x,&y);
    if(sqrt(x*x+y*y)<=d){ans++;}
}
printf("%d\n",ans);
return 0;
}


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

int main(void) {
    int a,b;
    int d,m;
    while (1){
        cin >> a;
        if (cin.eof())
            break;
        cin >> b;
        int l=max(a,b);
        int s=min(a,b);
        int n;
        while (1){
            n=l%s;
            if (n==0){
                d=s;
                break;
            }
            l=s;
            s=n;
        }
        m=a*(b/d);
        cout << d << " " << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  ll n;
  string s;
  cin >> n;
  cin >> s;

  ll cnt = 0;
  for (size_t i = 0; i <= n - 3; i++) {
    if (s.substr(i, 3) == "ABC") {
      cnt++;
    }
  }
  
  cout << cnt << endl;
}


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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, A, B;
   cin >> N >> A >> B;
   string S;
   cin >> S;

   int count_b = 0, clear = 0;

   for (int i = 0; i < N; i++) {
     if(S.at(i) == 'a') {
       if (clear < A + B) {
         cout << "Yes" << endl;
         clear++;
       }
       else {
         cout << "No" << endl;
       }
     }
     else if (S.at(i) == 'b') {
       if (clear < A + B && count_b < B) {
         cout << "Yes" << endl;
         count_b++;
         clear++;
       }
       else {
         cout << "No" << endl;
         count_b++;
       }
     }
     else cout << "No" << endl;
   }
 }


Measured memory_bytes: 896
#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()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n;
	std::cin >> n;
	std::vector<int> d(n);
	rep(i,n)std::cin >> d[i];;
	sort(all(d));
	std::cout << d[n/2]-d[n/2-1]<< std::endl;
	
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>x(n);
  for(int i=0;i<n;i++){
    int y;
    cin>>y;
    x[y-1]++;
  }
  sort(x.begin(),x.end());
  reverse(x.begin(),x.end());
  int ans=0;
  for(int j=0;j<n-k;j++){
  ans+=x[n-1-j];
  x.pop_back();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


void solve() {
	ld r; cin >> r;
	cout << 2 * pi*r << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(4);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 3968
#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;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int dp[50][1<<17];
int fow,s,ans;
const int mod = 1e9+7;

void test_case(){
	int x,y,z,n;
	cin >> n >> x >> y >> z;
	ans = 1;
	for(int i = 1; i <= n ; i++)
		ans = 1ll*ans*10%mod;
	s = (1<<(x+y+z))-1;
	fow = (1<<(x-1))|(1<<(x+y-1))|(1<<(x+y+z-1));
	dp[0][0] = 1;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 0 ; j <= s ; j++){
			for(int k = 1 ; k <= 10 ; k++){
				int t = (j<<k)|(1<<(k-1));
				t&=s;
				if((t&fow)!=fow){
					dp[i][t] = (dp[i][t]+dp[i-1][j])%mod;
				}
			}
		}
	}
	for(int i = 0 ; i <=s ; i++)
		ans = (ans-dp[n][i]+mod)%mod;
	cout<<ans;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 22272
#include <stdio.h>
#include <string.h>
#include <algorithm>

using ll = long long int;

ll gcd(ll a_, ll b_)
{
	if (b_ == 0)return a_;
	return gcd(b_, a_% b_);
}

const ll MAX_N = 100;
ll memo[MAX_N + 1];
ll p[MAX_N + 1], q[MAX_N + 1];
ll r[MAX_N + 1], b[MAX_N + 1];
ll n;
ll dp(int x_)
{
	if (memo[x_] > 0)return memo[x_];
	dp(r[x_]); dp(b[x_]);
	ll a_ = memo[r[x_]]; ll b_ = memo[b[x_]];
	ll c_ = p[x_] / gcd(p[x_], q[x_]);
	ll d_ = q[x_] / gcd(p[x_], q[x_]);
	return memo[x_] = a_ * b_ * (c_ + d_) / gcd(a_*c_, b_*d_);
}

int main()
{
	for (;;)
	{
		scanf("%lld",&n);
		if (n == 0)break;
		for (int i = 1; i <= n; ++i)scanf("%lld %lld %lld %lld",p + i,q + i,r + i,b + i);
		memset(memo, 0, sizeof(memo));
		memo[0] = 1;
		ll ans = 0;
		for (int i = 1; i <= n; ++i)
		{
			ans = std::max(dp(i),ans);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<int> ruiLeft(N+1), ruiRight(N+1);
    for (int i = 0; i < N; i++) {
        ruiLeft[i+1] = (ruiLeft[i] ^ a[i]);
    }
    for (int i = N-2; i >= 0; i--) {
        ruiRight[i] = (ruiRight[i+1] ^ a[i+1]);
    }
    rep(i, N) {
        if (i) cout << " ";
        cout << (ruiLeft[i] ^ ruiRight[i]);
    }
    cout << endl;

}


Measured memory_bytes: 5544
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int N, M; cin >> N >> M;
	cout << ((N - M) * 100 + M * 1900) * pow(2, M) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)

int main()
{
    fast_cin();
    string s;
    cin>>s;
    ll k;
    cin>>k;
    ll init = 0;
    ll cnt1 = 0, cnt2 = 0;
    while(init < s.size())
    {
    	if(s[0] == s[init])
    	{
    		init++;
    		cnt1++;
    	}
    	else
    	{
    		break;
    	}
    }
    bool flg = 0;
    if(init == s.size())
    {
    	flg = 1;
    }
    ll end = s.size()-1;
    while(end >= 0)
    {
    	if(s[s.size()-1] == s[end])
    	{
    		end--;
    		cnt2++;
    	}
    	else
    	{
    		break;
    	}
    }
   	if(flg)
   	{
   		cout<<k*s.size()/2<<'\n';
   	}
   	else
   	{
   		if(s[0] == s[s.size()-1])
   		{
   			ll ans = 0;
   			ll i = init;
   			while(i <= end)
   			{
   				ll j = i;
   				ll cnt = 0;
   				while(j < s.size() && s[j] == s[i])
   				{
   					j++;
   					cnt++;
   				}
   				ans += cnt/2;
   				i = j;	
   			}
   			ans *= k;
   			ans += cnt1/2;
   			ans += cnt2/2;
   			ans += (k-1)*((cnt1+cnt2)/2);
   			cout<<ans<<'\n';
   		}
   		else
   		{
   			init = 0;
   			ll ans = 0;
   			while(init < s.size())
   			{
   				ll j = init;
   				ll cnt = 0;
   				while(j < s.size() && s[j] == s[init])
   				{
   					j++;
   					cnt++;
   				}
   				ans += cnt/2;
   				init = j;
   			}
   			cout<<ans*k<<'\n';
   		}
   	}
    return 0;
}


Measured memory_bytes: 256
# @author 

import sys

class EKnapsack2:
    def solve(self):
        n, W = [int(_) for _ in input().split()]
        w = [0] * (n + 1)
        v = [0] * (n + 1)
        for i in range(1, n + 1):
            w[i], v[i] = [int(_) for _ in input().split()]

        V = sum(v)
        dp = [[float('inf')] * (n + 1) for _ in range(V + 1)]

        for ve in range(V + 1):
            dp[0][0] = 0
            for k in range(1, n + 1):
                dp[ve][k] = dp[ve][k - 1]
                if ve >= v[k]:
                    dp[ve][k] = min(dp[ve][k], dp[ve - v[k]][k - 1] + w[k])

        ans = 0
        for ve in range(V + 1):
            if dp[ve][n] <= W:
                ans = ve

        print(ans)

solver = EKnapsack2()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 220552
import math
N = int(input())
C = [0] * N 
S = [0] * N
F = [0] * N

for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

for j in range(N-1):
    ans = 0
    for i in range(j, N-1):
        tmp = math.ceil(ans/F[i]) * F[i]
        tmp2 = max(tmp, S[i])
        ans = tmp2
        ans += C[i]

    print(ans)
print(0)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int b=0,r=0;
    string s;
    int n;
    cin >> n;
    cin >> s;

    rep(i,n){
        if(s[i] == 'R') r++;
        else b++;
    }

    if(r > b)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define int long long
#define PII pair<int,int>
#define maxn 1000005
#define ll long long 
#define fi first
#define int ll
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std; 
int n,m;
const int mo=998244353;
int a[305][305];
void SWAP(int x,int y)
{ rep(i,1,m) swap(a[x][i],a[y][i]);}
void solve(int x,int y)
{rep(i,1,m) a[x][i]^=a[y][i];
}
signed main()
{ cin>>n>>m;
  rep(i,1,n)rep(j,1,m) cin>>a[i][j];
  int r=0;
  rep(i,1,m)
  {int k=0; 
   rep(j,r+1,n) if(a[j][i]){k=j;break;}
   if(k) {r++;}
   else continue;
   SWAP(r,k);
   rep(p,1,n)
   {if((p!=r)&&a[p][i])
     solve(p,r);
   }
  }
  int add=1;
  rep(i,1,n+m-1) add=(add*2)%mo;
  int del=1;
  rep(i,1,n+m-r-1) del=(del*2)%mo;
  cout<<(add-del+mo)%mo<<endl; 
	
	
	
return 0;	
}

Measured memory_bytes: 1024
s = input()

slist = [i for i in s]

sset = set(slist)

def a():
    if len(sset) == 2:
        for i in sset:
            cnt = 0
            for j in slist:
                if i == j:
                    cnt += 1
            if cnt == 2:
                print("Yes")
                return
            else:
                print("No")
                return
    else:
        print("No")
        return

a()

Measured memory_bytes: 3060
N = int(input())
a = list(map(int, input().split()))
if N == 1:
    if a[0] != 1:
        print(1)
        exit()
    else:
        print(0)
        exit()
a.sort()
A = 0
c = 0
while True:
    try:
        #print(a)
        A = a[0]
        if len(a)>1:
            for i in range(1, len(a)):
                if a[i] != A:
                    # print(i + 1)
                    # c += i
                    del a[:i]
                    if i >= A:
                        c += i - A
                    else:
                        c += i
                    # print(a[i], c)
                    break
                elif i == len(a) - 1:
                    if i + 1 >= A:
                        c += i + 1 - A
                    else:
                        c += i + 1
                    print(c)
                    exit()
        else:
            print(c + 1)
            exit()
    except IndexError:
        break


Measured memory_bytes: 14620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct data{
	string s;
	vector<int> vi;
};

bool comp(data d1, data d2){
	return d1.s < d2.s;
}

int main(){
	int n;
	vector<data> vd;
	string s;
	while(cin >> s >> n){
		int i = 0;
		while(i < vd.size() && vd[i].s != s) i++;
		if(i == vd.size()){
			data d;
			d.s = s;
			vd.push_back(d);
		}	
		vd[i].vi.push_back(n);
		sort(vd[i].vi.begin(), vd[i].vi.end());
	}
	sort(vd.begin(), vd.end(), comp);
	for(int i = 0; i < vd.size(); i++){
		cout << vd[i].s << endl;
		for(int j = 0; j < vd[i].vi.size(); j++){
			if(j != 0) cout << " ";
			cout << vd[i].vi[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (size_t i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

long long solve(int n, vector<int>& a)
{
    long long ans = 0;
    int r = 0, sum_xor = 0, sum = 0;
    REP(l, n) {
        while (r < n && (sum_xor ^ a[r]) == (sum + a[r])) {
            sum_xor ^= a[r];
            sum     += a[r];
            ++r;
        }

        sum_xor ^= a[l];
        sum     -= a[l];
        ans     += r - l;
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n)
        cin >> a[i];
    cout << solve(n, a) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint s = 0, n, a = 0, b = 0, c = 0, d = 0, e = 0;
  cin >> n;
  rep(i, n){
    string t;
    cin >> t;
    if(t[0] == 'M') ++a;
    if(t[0] == 'A') ++b;
    if(t[0] == 'R') ++c;
    if(t[0] == 'C') ++d;
    if(t[0] == 'H') ++e;
  }
  s += a * b * c;
  s += a * b * d;
  s += a * b * e;
  s += a * c * d;
  s += a * c * e;
  s += a * d * e;
  s += b * c * d;
  s += b * c * e;
  s += b * d * e;
  s += c * d * e;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
open System

// prelude
let readStr () = stdin.ReadLine()

let reads f () = readStr().Split() |> Array.map f

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,M)=readInts()|>pair
let A=reads int64 () |> Array.mapi (fun i x -> x,i) |> Set.ofArray

seq {1..M}
|> Seq.fold (fun set _ ->
  let ((x,i) as m)=Set.maxElement set
  set
  |> Set.remove m
  |> Set.add (x/2L,i)
) A
|> Set.fold (fun s (x,_) -> s+x) 0L
|> printfn "%d"

Measured memory_bytes: 42708
K,N = gets.split(" ").map(&:to_i)
A = gets.split(" ").map(&:to_i)

b = [K-A[N-1]+A[0]]
(N-1).times do |i|
  b.push(A[i+1]-A[i])
end
b.sort!
c = 0
(N-1).times do |i|
  c += b[i]
end

puts c

Measured memory_bytes: 19256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    string s;
    cin >> s;
    cout << "ABC" << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define H 500000

void buildMaxHeap(int *);
void maxHeapify(int *, int);
int parent(int);
int left(int);
int right(int);

int size = 0;

int main(){

  int A[H];
  int i = 0;
  
  scanf("%d",&size);
  for(i = 1; i <= size; i++){//1-origin
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);

  for(i = 1; i <= size; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  return 0;
}

void buildMaxHeap(int *A){
  int i = 0;
  
  for(i = size/2; i >= 1; i--){
    maxHeapify(A,i);
  }
}

void maxHeapify(int *A, int i){
  int l = left(i), r = right(i), largest = 0;
  int keep = 0;

  //left, right and me top of the world
  if(l <= size && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }

  if(r <= size && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    //A[i] koukan A[largest]
    keep = A[i];
    A[i] = A[largest];
    A[largest] = keep;
    maxHeapify(A, largest);
  }
}

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}



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

const int N=2005;

int n,m,a[N][N];

void solve(int x)
{
	if (x==1) {a[1][1]=1;return;}
	solve(x-1);
	int n=1<<(x-1);
	for (int i=1;i<n;i++)
		for (int j=1;j<n;j++)
			a[i+n][j]=a[i][j+n]=a[i+n][j+n]=a[i][j];
	a[n][n]=1;
}

int main()
{
	scanf("%d%d",&n,&m);
	solve(std::max(n,m));
	for (int i=1;i<(1<<n);i++)
	{
		for (int j=1;j<(1<<m);j++) putchar(a[i][j]+'0');
		puts("");
	}
	return 0;
}

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

typedef long long ll;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);	
  ll n;
  cin>>n;
  vector<ll> arr(n+1);
  for(ll i=1;i<=n;i++)
    cin>>arr[i];
  vector<ll> ans(n+1);
  for(ll i=n;i;i--){
    ll sum=0;
  	for(ll j = 2*i;j<=n;j+=i)
      if(ans[j])
        sum++;
    if(arr[i]%2 != sum%2)
      ans[i]=1;
  }
  vector<ll> fin;
  for(ll i=1;i<=n;i++)
    if(ans[i])
      fin.push_back(i);
  cout<<fin.size()<<endl;
  for(auto i:fin)
    cout<<i<<" ";
cout<<endl;
    return 0;
}

Measured memory_bytes: 7236
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int swap = 0;
        for (int i = 0; i < n - 1; i++) {
            if (a[i] != i + 1) continue;
            int tmp = a[i];
            a[i] = a[i + 1];
            a[i + 1] = tmp;
            swap++;
        }
        if (a[n - 1] == n) {
            swap++;
        }
        System.out.println(swap);
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 37192
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum
 
total=0
for i in range(n+1): #1-10 1,2,10
    sum=check(i)
    if sum<=b and sum>=a:
        #print(i)
        total=total+i

print(total)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

#define li long long int
#define FOR(i, a, b) for (li (i) = (a) ; (i) < (b) ; ++(i))
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    li N, M;
    cin >> N >> M;

    vector<li> d;
    li sqrtM = sqrt(M);
    FOR(i, 1, sqrtM + 1) {
        if (M % i == 0) {
            d.push_back(i);
            d.push_back(M / i);
        }
    }

    li answer = 0;
    li upper = M/N;
    sort(d.begin(), d.end());
    for(li x: d) {
        if (x > upper) {
            break;
        }
        answer = x;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define DIM 100005
using namespace std;
int n, m, i, p, u, okp, oku, x, y, nod, vecin;
int viz[DIM], c[2 * DIM];
vector<int> v[DIM];
int main(){
    cin>> n >> m;
    for(i = 1; i <= m; i++){
        cin>> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    viz[1] = 1;
    p = u = n;
    c[p] = 1;
    while(okp == 0 || oku == 0){
        okp = oku = 1;
        nod = c[p];
        for(i = 0; i < v[nod].size(); i++){
            vecin = v[nod][i];
            if(viz[vecin] == 0){
                okp = 0;
                c[--p] = vecin;
                viz[vecin] = 1;
                break;
            }
        }
        nod = c[u];
        for(i = 0; i < v[nod].size(); i++){
            vecin = v[nod][i];
            if(viz[vecin] == 0){
                oku = 0;
                c[++u] = vecin;
                viz[vecin] = 1;
                break;
            }
        }
    }
    cout<< u - p + 1 <<"\n";
    for(i = p; i <= u; i++){
        cout<< c[i] <<" ";
    }
}


Measured memory_bytes: 7040
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>
 
using namespace std;
 
template<class T = int,T divided_by = 10>
constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; }
template<class T = int,T divided_by = 10>
constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; }
 
template<class T = int> T gcd(T a, T b){ return b ? gcd(b,a%b) : a; }
template<class T = int> T lcm(T a, T b){ return a / gcd(a,b) * b; }
template<class T = int> T lcm_safe(T a, T b){ T p = a/gcd(a,b); return (b <= PINF<T>()/p) ? p*b:PINF<T>(); }
//オーバーフローするとき+INFを返す
//
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
 
    long long a,b;
    cin >> a >> b;
    if(a==1) a = 14;
    if(b==1) b = 14;
    if(a==b) {
        cout << "Draw" << endl;
        return 0;
    }
    if(a>b) {
        cout << "Alice" << endl;
        return 0;
    }
    cout << "Bob" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))


signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s; cin >> s;
    int n=s.size();
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-i+1;j++){
            string ss=s.substr(j,i);
            bool ok=1;
            rep(j,ss.size()){
                if(ss[j]!='A'&&ss[j]!='T'&&ss[j]!='C'&&ss[j]!='G') ok=0;
            }
            if(ok) chmax(ans,i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func F(a, b int64) int {
	var ans int
	for a > 0 || b > 0 {
		a /= 10
		b /= 10
		ans++
	}
	return ans
}

func main() {
	defer stdout.Flush()
	n := readInt64()
	if n == 1 {
		println(1)
		return
	}
	ans := math.MaxInt32
	for i := int64(1); i*i <= n; i++ {
		if n%i == 0 {
			ans = minInt(ans, F(i, n/i))
		}
	}
	println(ans)
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>
#include <limits>

intmax_t parse_int(std::string const& s, size_t& i) {
  assert(isdigit(s[i]));
  intmax_t res = s[i]-'0';
  while (isdigit(s[++i]))
    res = res*10 + s[i]-'0';
  return res;
}

intmax_t apply(intmax_t lhs, char op, intmax_t rhs) {
  if (op == '+') return lhs + rhs;
  if (op == '-') return lhs - rhs;
  if (op == '*') return lhs * rhs;
  assert(false);
}

intmax_t parse(std::string const& s, size_t& i, std::vector<std::string> const& ops, size_t preced = 0) {
  if (preced == ops.size()) {
    if (isdigit(s[i])) return parse_int(s, i);
    if (s[i] == '(') {
      intmax_t res = parse(s, ++i, ops, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    assert(false);
  }
  intmax_t res = parse(s, i, ops, preced+1);
  while (i < s.length()) {
    char op = s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    res = apply(res, op, parse(s, ++i, ops, preced+1));
  }
  return res;
}

int main() {
  char buf[256];
  scanf("%s", buf);
  std::string s = buf;

  intmax_t res = std::numeric_limits<intmax_t>::min();
  for (size_t i = 0; i < 3; ++i) {
    for (size_t j = 0; j < 3; ++j) {
      for (size_t k = 0; k < 3; ++k) {
        std::vector<std::string> ops(3);
        ops[i].push_back('+');
        ops[j].push_back('-');
        ops[k].push_back('*');
        while (ops.back().empty()) ops.pop_back();
        bool valid = true;
        for (auto const& opsi: ops) {
          if (opsi.empty()) {
            valid = false;
            break;
          }
        }
        if (!valid) continue;

        size_t p = 0;
        res = std::max(res, parse(s, p, ops));
      }
    }
  }
  printf("%jd\n", res);
}



Measured memory_bytes: 2880
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(scanf("%d %d",&h,&w)){
    int count=0;
    if(h==0 && w==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(count==0){
	  printf("#");
	  count=1;
	}
	else{
	  printf(".");
	  count=0;
	}
      }
      printf("\n");
      if(w%2 ==0){
	if(count==0)count=1;
	else count=0;
      }
    }
    printf("\n");
  }
  return(0);
}

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

int main() {

  double a;

  while( cin >> a ) {

    double ans = 0.00;
    for ( int i = 0; i < 10; i++ ) {
      ans += a;
      if ( ( i % 2 ) == 0 ) {
	a *= 2;
      }else {
	a /= 3;
      }
    }
    cout << fixed << setprecision(10) << ans << endl;

  }

  return 0;

}

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

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a,b,c;
  cin>>a>>b>>c;
  int done=max(0,min(a-b,c));
  cout<<c-done<<endl;
  return 0 ;
}


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

using namespace std;

#define INF 0x3f3f3f3f
typedef long long LL;
const int N = 1e5 + 10;
double a[N*2];
int n, k;
bool check(double x) {
    int ans=0;
    for (int i=1;i<=n;++i) {
        ans+=int(a[i]/x);
    }
    if (ans>k) return false;
    else return true;
}
void solve()
{
    cin>>n>>k;
    double m=0;
    for (int i=1;i<=n;++i) {
    	cin>>a[i]; 
    	a[i]=a[i]-0.001; 
    	m=max(m, a[i]);
    }
    double l=0, r=m;
    while ((r-l)>1e-6) {
        double mid=(l+r)/2;
        if (check(mid)) {
            r=mid;
        }
        else {
            l=mid;
        }
    }
    r=ceil(r);
    printf("%.0lf\n",r);

}
int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // freopen("data1.txt", "r", stdin);
    // freopen("data2.txt", "w", stdout);
    int _ = 1;
    // cin >> _;
    for (int i = 1; i <= _; ++i)
        solve();
    // system("pause");
}

Measured memory_bytes: 5276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, sz(s)) ans += s[i] != t[i];
    cout << ans << endl;
}

Measured memory_bytes: 3924
import math
def c168(a, b, h, m):

    hh = h*30+0.5*m
    mm = 6*m

    kaku = abs(hh - mm) if 180 >= abs(hh - mm) else 360 - abs(hh - mm)

    ss = math.cos(kaku*math.pi/180)

    ans = math.sqrt((a**2 + b**2-2*a*b*ss))

    return ans

def main():
    a, b, h, m = map(int, input().split())
    print(c168(a, b, h, m))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9408
import java.util.*;

public class Main {

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

    if (n % k == 0) {
      System.out.println(0);
    } else {
      System.out.println(1);
    }

  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	ll n;
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		if (i * (i + 1) / 2 >= n) {
			for (ll j = i; j >= 1; j--) {
				if (n - j >= 0) {
					n -= j;
					cout << j << endl;
				}
			}
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  int i=1;
  int n,x,y;
  scanf("%d",&n);
  do{
    x=i;
    y=x;
    if(x%3==0)
      printf(" %d",y);
    else 
      do{
	if(x%10==3){
	  printf(" %d",y);
	  break;
	}
      }while(x/=10);
  }while(++i<=n);
  printf("\n");
  return(0);
}

Measured memory_bytes: 600
#include <stdio.h>

int main(){
	int n, m, l, i, j ,k;
	long line_a[101][101], line_b[101][101], line_c[101][101];
	scanf("%d %d %d", &n, &m, &l);
	// INPUT
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%ld", &line_a[i][j]);
		}
	}
	for(i = 0;i < m;i++){
		for(j = 0;j < l;j++){
			scanf("%ld", &line_b[i][j]);
		}
	}
	// CALC AND OUTPUT
	for(i = 0;i < n;i++){
		for(j = 0;j < l;j++){
		    if(j != 0) printf(" ");
			for(k = 0;k < m;k++){
				if(k == 0) line_c[i][j] = 0;
				line_c[i][j] += line_a[i][k] * line_b[k][j];
			}
			printf("%ld", line_c[i][j]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2124