akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

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

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll x;
    x=min(b-1,n);
    ll ans=a*x/b-a*(x/b);
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a/b;
        int r = a%b;
        System.out.print(d+" "+r+" ");
        double f = (double)a/(double)b;
        System.out.printf("%.5f\n", f); 
        
        sc.close();
    }
}



Measured memory_bytes: 26372
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s; cin>>s;
    if(s=="SUN"){
        cout<<7<<endl;
    }else if(s=="MON"){
        cout<<6<<endl;
    }else if(s=="TUE"){
        cout<<5<<endl;
    }else if(s=="WED"){
        cout<<4<<endl;
    }else if(s=="THU"){
        cout<<3<<endl;
    }else if(s=="FRI"){
        cout<<2<<endl;
    }else if(s=="SAT"){
        cout<<1<<endl;
    }
    
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

ld ans;
int n, a[N];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   ans = a[1];
   for (int i = 2; i <= n; i ++) {
      ans += a[i];
      ans /= 2.0;
   }
   cout << fixed << setprecision (5) << ans;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] alphabetCount = new int[26];


        /// S0
        char[] chars = sc.next().toCharArray();
        for (int i = 0; i < chars.length; i++) {
            int index = chars[i] - 97;
            alphabetCount[index] = alphabetCount[index] + 1;
        }

        // S1 to Sn-1
        for (int i = 1; i < N; i++) {
            chars = sc.next().toCharArray();

            int[] tempAlphabetCount = new int[26];
            for (int j = 0; j < chars.length; j++) {
                int index = chars[j] - 97;
                tempAlphabetCount[index] = tempAlphabetCount[index] + 1;
            }
            for (int j = 0; j < 26; j++) {
                alphabetCount[j] = Math.min(tempAlphabetCount[j], alphabetCount[j]);
            }
        }

        String ans = "";
        for (int i = 0; i < 26; i++) {
            if (alphabetCount[i] > 0) {
                for (int j = 0; j < alphabetCount[i]; j++) {
                    ans += (char)(i + 97);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
n,k = map(int, input().split())
a = list(map(int, input().split()))
row = []
been = [0]*n
now = 0
nex = 0
t = 0
l = [-1]*n
prev = 0
while been[now] == 0:
    l[now] = t
    row.append(now)
    been[now] = 1
    now = a[now]-1
    t += 1
    if been[now] == 1:
        prev = l[now]
# print(prev,t)
print(row[prev + (k-prev)%(t-prev)]+1 if k > prev else row[k]+1)


Measured memory_bytes: 33928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
const int INF=1e9;
struct SegmentTree{
	int n;
	vector<int> tree,tagcg,tagadd,needcg;
	SegmentTree(int n):n(n),tree(n*4),tagcg(n*4),tagadd(n*4),needcg(n*4){};
	void push_up(int p) {
		tree[p]=min(tree[p<<1],tree[p<<1|1]);
	}
	void add(int p,int dx) {
		tree[p]+=dx;
		tagadd[p]+=dx;
	}
	void update(int p,int L) {
		tree[p]=L+1;
		tagadd[p]=0;
		needcg[p]=1;
		tagcg[p]=L;
	}
	void push_down(int l,int r,int p){
		if(needcg[p]) {
			int mid=l+r>>1;
			update(p<<1,tagcg[p]);
			update(p<<1|1,tagcg[p]+mid-l+1);
			needcg[p]=0;
		}
		add(p<<1,tagadd[p]);
		add(p<<1|1,tagadd[p]);
		tagadd[p]=0;
	}
	void update(int l,int r,int L,int nl,int nr,int p){
		if(nl>=l&&nr<=r) {update(p,L);return;}
		push_down(nl,nr,p);int mid=nl+nr>>1;
		if(l<=mid) update(l,r,L,nl,mid,p<<1);
		if(r>mid) update(l,r,L+mid-nl+1,mid+1,nr,p<<1|1);
		push_up(p);
	}
	void add(int l,int r,int dx,int nl,int nr,int p) {
		if(l>r) return;
		if(nl>=l&&nr<=r) {add(p,dx);return;}
		push_down(nl,nr,p);int mid=nl+nr>>1;
		if(l<=mid) add(l,r,dx,nl,mid,p<<1);
		if(r>mid) add(l,r,dx,mid+1,nr,p<<1|1);
		push_up(p);
	}
	int query() {return tree[1];}
	int query(int k,int nl,int nr,int p) {
		if(k<1) return INF;
		if(nl==nr) return tree[p];
		int mid=nl+nr>>1;push_down(nl,nr,p);
		if(k<=mid) return query(k,nl,mid,p<<1);
		return query(k,mid+1,nr,p<<1|1);	
	}
};
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);cout.tie(nullptr);
	int n,m;cin>>n>>m;
	SegmentTree tree(m);
	for(int i=1;i<=n;i++) {
		int l,r;cin>>l>>r;
		int L=tree.query(l-1,1,m,1);
		tree.add(1,l-1,1,1,m,1);
		tree.add(r+1,m,1,1,m,1);
		tree.update(l,r,L-l+2,1,m,1);
		// for(int i=1;i<=m;i++) cout<<tree.query(i,1,m,1)<<' ';cout<<endl;
		int ans=tree.query();
		if(ans>=INF) ans=-1;
		cout<<ans<<endl;
	}
    return 0;
}

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

int base_change(int n, int k){
	int ans = 0;
	while(n>0){
		ans++;
		n = n/k;
	}
	return ans;
}

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

	int n,k;
	cin >> n >> k;
	cout << base_change(n,k);
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    double d;
    cin>>d;
    a[i]=(ll)(round(d*1e9));
  }
  map<pair<int, int>, int>m;
  for(auto x : a)
  {
    int t=0;
    while(x%2==0)
    {
      	t++;
     	x/=2;
    }
    int f=0;
    while(x%5==0)
    {
      f++;
      x/=5;
    }
    m[{t,f}]++;
  }
  ll ans=0;
  for(auto x : m)
  {
    for(auto y : m)
    {
      if((x.first.first + y.first.first)>=18 && (x.first.second + y.first.second)>=18)
      {
        if(x==y)ans+=(long long)x.second*(x.second-1)/2;
        else if(y>x)ans+=(long long)x.second*y.second;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4852
use std::io::*;
use std::str::*;

fn scan_token<T: FromStr>() -> T {
    stdin().bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
        .parse::<T>().ok().unwrap()
}

fn scan_line<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map( |token| token.parse::<T>().ok().unwrap() ).collect()
}

fn main() {
    let s: String = scan_token();
    let k: i64 = scan_token();

    let ans = s.chars()
        .take(k as usize)
        .skip_while(|&c| c == '1')
        .next().unwrap_or('1');

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

Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
import collections
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

for i in range(N - 1):
    a,b = map(int,input().split())
    Graph[a].append(b)
    Graph[b].append(a)

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)
todo = collections.deque()

seen[1] = True
todo.append(1)

while len(todo) != 0:
    v = todo.pop()
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        seen[next_v] = True
        todo.append(next_v)
        counter[next_v] += counter[v]

print(*counter[1:])

Measured memory_bytes: 105932
N, A, B = map(int, input().split())
if N == 1:
  if A == B:
    print(1)
  else:
    print(0)
else:
  if A > B:
    print(0)
  elif A == B or N == 2:
    print(1)
  else:
    print((B-A) * (N-2) + 1)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int x, y;
    while(true){
        cin >> x >> y;
        if ( x == 0 && y == 0 ) break;
        if ( x < y ){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3000
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,x;
    cin >> a >> b >> x;
    bool ok = x >= a && x <= a + b;
    if(ok){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
 using namespace std ;
 int main()
{
short int c=0;
char s[3];

cin>>s;

if(((s[0]=='a')&&(s[1]=='b')&&(s[2])=='c')||
  ((s[0]=='a')&&(s[1]=='c')&&(s[2])=='b')||
  
((s[0]=='b')&&(s[1]=='a')&&(s[2])=='c')||
((s[0]=='b')&&(s[1]=='c')&&(s[2])=='a')||

((s[0]=='c')&&(s[1]=='b')&&(s[2])=='a')||
((s[0]=='c')&&(s[1]=='a')&&(s[2])=='b'))

 cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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;
}

const int INF = 1e9;
const long long LINF = 1e18;

long long pow5(long long x) {
    return x * x * x * x * x;
}

int main() {
    long long X;
    cin >> X;

    double hoge = pow(X, 1.0 / 3.0);
    // cout << hoge << endl;
    for (long long B = -hoge - 2; B < hoge + 2; B++) {
        long long A = pow(X + pow5(B), 1.0 / 5.0);
        if (pow5(A) == X + pow5(B)) {
            cout << A << ' ' << B << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
  long N,A,B;
  scanf("%ld%ld%ld",&N,&A,&B);
  if(N%(A+B)==0)
  {
    printf("%ld",N/(A+B)*A);
  }
  else
  {
    if(N%(A+B)>=A)
    {
      printf("%ld",N/(A+B)*A+A);
    }
    else
    {
      printf("%ld",N/(A+B)*A+N%(A+B));
    }
  }
}
    

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

int main(){
    int L, R;
    cin >> L >> R;
    if(R - L > 2018){
        cout << 0 << endl;
        return 0;
    }
    L %= 2019;
    R %= 2019;
    int min = 2019;
    // cout << L << " "<< R << endl;
    for(int i = L; i%2019 != R; i++){
        for(int j = i + 1; j%2019 != (R + 1)%2019; j++){
            if(i*j%2019 < min) min = i*j%2019;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int N, M, Q;
vector<vector<int>> G, ans;

void f(int v, int d, int c) {
    int i;
    for(i = d; i >= 0 && ans[v][i] == 0; i--)
        ans[v][i] = c;
    if(i != d)
        for(int u : G[v])
            f(u, d - 1, c);
}

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

    cin >> N >> M;
    G.resize(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cin >> Q;
    vector<int> v(Q), d(Q), c(Q);
    rep(i, Q) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    ans.assign(N, vector<int>(11));
    while(Q--)
        f(v[Q], d[Q], c[Q]);

    rep(i, N) cout << ans[i][0] << endl;

    return 0;
}

Measured memory_bytes: 16248
N, K = map(int, input().split())

if K == 0:
    print(N**2)
    exit()

ans = 0
for div in range(K + 1, N + 1):
    cnt = N // div
    ans += cnt * (div - K)
    ans += max(0, (N % div) - K + 1)

print(ans)

Measured memory_bytes: 2940
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        N: usize
    }
    let mut count = [0u128; 100 * 100 + 1];
    for x in 1..=N {
        let mut i = 2;
        let mut temp = x;
        while i * i <= temp {
            while temp % i == 0 {
                count[i] += 1;
                temp /= i;
            }
            i += 1;
        }
        count[temp] += 1;
    }
    let primes = &count[2..];
    let two = primes.iter().filter(|x| **x >= 2).count() as i128;
    let four = primes.iter().filter(|x| **x >= 4).count() as i128;
    let fourteen = primes.iter().filter(|x| **x >= 14).count() as i128;
    let twenty_four = primes.iter().filter(|x| **x >= 24).count() as i128;
    let seventy_four = primes.iter().filter(|x| **x >= 74).count() as i128;

    let two_four_four = four * (four - 1) * (two - 2) / 2;
    let four_fourteen = fourteen * (four - 1);
    let two_24 = twenty_four * (two - 1);
    println!("{}", seventy_four + two_four_four + four_fourteen + two_24);
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a;
  cin >>a;
  
  if(a<1200) puts("ABC");
  else if (a<2800) puts("ARC");
  else puts("AGC");
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define mod 1000000007
using namespace std;


ll solv(vector<bool> sw,vvl &ngo,vl &p,ll d){
    if(d == sw.size()){
        for(int i=0;i<p.size();++i){
            ll count = 0;
            for(int j=0;j<ngo[i].size();++j) if(sw[ngo[i][j]]) count++;
            if(count%2 != p[i]) return 0;
        }return 1;
    }else{
        ll ret = 0;
        sw[d] = true;
        ret = solv(sw,ngo,p,d+1);
        sw[d] = false;
        return ret + solv(sw,ngo,p,d+1);
    }
}

int main(void){
    ll n,m; cin>>n>>m;
    vvl ngo(m);
    for(int i=0;i<m;++i){
        ll k; cin>>k;
        for(int j=0;j<k;++j){
            ll t; cin>>t;
            ngo[i].push_back(t-1);
        }
    }
    vl p(m);
    for(int i=0;i<m;++i) cin>>p[i];
    cout<<solv(vector<bool>(n),ngo,p,0)<<endl;
}


Measured memory_bytes: 256
from math import floor
from copy import deepcopy

def calc(a,b):
  ret=a**4+b**4+a*b*(a**2+a*b+b**2)
  return ret

X=int(input())
p=floor(X**0.5)

q=[]
for i in range(1,p+1):
  if X%i==0:
    q.append([i,X//i])
    
for kumi in q:
  s=kumi[0]
  t=kumi[1]
  #print(s,t)
  for A in range(p):
    B=A-s
    if calc(A,B)==t:
      print(A,B)
      break

Measured memory_bytes: 9548
s = input()
a = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 'R'or s[i] == 'U'or s[i] == 'D':
            a += 1

    elif s[i] == 'L'or s[i] == 'U'or s[i] == 'D':
        a += 1

if a == len(s):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

bool plusInteger(double a)
{
    if (floor(a) == ceil(a))
    {
        if (floor(a) >= 0)
        {
            return 1;
        }else
        {
            return 0;
        }
        
    }else
    {
        return 0;
    }
    
}

int main(int argc, char const *argv[])
{
    double R, G, B, N;
    cin >> R >> G >> B >> N;

    int sum = 0;
    double b;
    for (int r = 0; r * R <= N; r++)
    {
        for (int g = 0; g * G <= N; g++)
        {
            b = (N - R * r - G * g) / B;
            if (plusInteger(b)) sum++;
        }
        
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

class DisjointSet {
  public:
    vector<ll> rank, p;

    DisjointSet() {}
    DisjointSet(ll size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      rep(i, size) p[i] = i;
    }

    bool same(ll x, ll y) {
      return find_set(x) == find_set(y);
    }

    void unite(ll x, ll y) {
      link(find_set(x), find_set(y));
    }

    void link(ll x, ll y) {
      if (x == y) return;

      if (rank[x] > rank[y]) {
        p[y] = x;
      } else {
        p[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
      }
    }

    ll find_set(ll x) {
      if (x != p[x]) {
        p[x] = find_set(p[x]);
      }
      return p[x];
    }
};

void solve() {
  ll n, m; cin >> n >> m;
  vector<ll> p(n);
  rep(i, n) {
    cin >> p[i];
    p[i]--;
  }
  DisjointSet ds = DisjointSet(n);
  rep(i, m) {
    ll x, y; cin >> x >> y;
    x--; y--;
    ds.unite(x, y);
  }
  ll ans = 0;
  rep(i, n) {
    if (ds.same(i, p[i])) ans++;
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 2560
while True:
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        break
    t = "{0}{1}" * (b//2) + ("\n" if b % 2 == 0 else "{0}\n")
    t1 = t.format("#",".")
    t2 = t.format(".","#")
    print((t1+t2) * (a//2) + ("" if a % 2 == 0 else t1))

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

typedef long long ll;
typedef long double ld;

using namespace std;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[101], b[101], c[101];
int main() {
	INeedIt();
	int n, sum=0;
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	for (int i=1;i<n;i++) cin>>c[i];
	sum+=b[a[1]];
	for (int i=2;i<=n;i++) {
		sum+=b[a[i]];
		if (a[i-1]+1==a[i]) sum+=c[a[i-1]];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    # s = input().rstrip()

    n = int(input().rstrip())

    if n == 1:
        print(1)
        return

    prev = 2
    ln = 1

    for i in range(2, n+1):
        tmp = prev + ln
        prev = ln
        ln = tmp

    print(ln)





if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007
#define INF 2000000009
typedef long long int lli;

int main(void) {
  lli N, a[MAX];
  scanf("%lld", &N);
  rep(i, 0, N) scanf("%lld", &a[i]);

  lli ans = INF;
  lli x = 0;
  lli y = 0;
  rep(i, 0, N) y += a[i];
  rep(i, 0, N-1) {
    x += a[i];
    y -= a[i];
    ans = min(ans, labs(x - y));
  } 
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n, m;
	cin >> n >> m;
	vector<int> ans(n, -1);
	bool flag = true;
	for (int i = 0; i < m; ++i){
		int s, c;
		cin >> s >> c;
		if (ans[s - 1] != -1 && ans[s - 1] != c){
			flag = false;
		}
		else{
			ans[s - 1] = c;
		}
	}
	if (!flag || (ans[0] == 0 && n > 1)){
		cout << -1;
		return 0;
	}
	for (int i = 0; i < n; ++i){
		if (ans[i] != -1) cout << ans[i];
		else if (i == 0 && n > 1) cout << 1;
		else cout << 0;
	}
	return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        a: usize,
        b: usize
    }
    println!("{}", 6-a-b);
}


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

unordered_map<long, long> mp;
unordered_map<long, long> mp2;
long aa[100010][60];

int main()
{
    int x;

    cin >> x;

    if(x >= 400 && x <= 599){
        cout << 8 << "\n";
    }else if(x >= 600 && x <= 799){
        cout << 7 << "\n";
    }
    else if (x >= 800 && x <= 999)
    {
        cout << 6 << "\n";
    }
    else if (x >= 1000 && x <= 1199)
    {
        cout << 5 << "\n";
    }
    else if (x >= 1200 && x <= 1399)
    {
        cout << 4 << "\n";
    }
    else if (x >= 1400 && x <= 1599)
    {
        cout << 3 << "\n";
    }
    else if (x >= 1600 && x <= 1799)
    {
        cout << 2 << "\n";
    }
    else if (x >= 1800 && x <= 1999)
    {
        cout << 1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

string X, Y;

void solve(int x_size, int y_size)
{
	vector< vector<int> > dp(x_size + 1, vector<int>(y_size + 1));

	for(int i = 0; i < x_size; ++i) {
		for(int j = 0; j < y_size; ++j) {
			if(X[i] == Y[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}
	}

	cout << dp[X.size()][Y.size()] << endl;
}

int main()
{
	int n;
	cin >> n;
	REP(i, n) {
		cin >> X >> Y;
		solve(X.size(), Y.size());
	}
	return 0;
}

Measured memory_bytes: 5036
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char S[4];
    int num;
    int waru, amari;
    
    scanf("%s", S);
    
    num = atoi(S);
    
    waru = num / 100;
    amari = num % 100;
    
    if (waru == 0 || waru > 12) {
        if (amari == 0 || amari  > 12) {
            printf("NA\n");
        } else {
            printf("YYMM\n");
        }
    } else if (amari == 0 || amari > 12) {
        if (waru == 0 || waru > 12) {
            printf("NA\n");
        } else {
            printf("MMYY\n");
        }
    } else {
        printf("AMBIGUOUS\n");
    }
    
    return 0;
}

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

using namespace std;
long long n,N[105],xian,hou;
int main()
{
 cin>>n;
 for(int i=0;i<n;i++)cin>>N[i];
 sort(N,N+n);
 for(int i=n-1;i>=0;i--)
 {
    if((n-1-i)%2==0)xian+=N[i];
    else hou+=N[i];
 }
 cout<<xian-hou<<endl;
 return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	ll N, T;
	cin >> N >> T;
	vll vt;
	ll i, j;
	for (i = 0; i < N; i++){
		ll t;
		cin >> t;
		vt.push_back(t);
	}
	ll ans = 0;
	for (i = N - 1; i >= 0; i--){
		if (i == N - 1){
			ans += T;
		}
		else{
			ans += min(T, vt[i + 1] - vt[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
n=int(input())
B=[False]*n
for i in range(n):
    d1,d2=map(int,input().split())
    B[i]=d1==d2
for i in range(n-2):
    if B[i] and B[i+1] and B[i+2]:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 62476
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt = 0;
    for( int i = 0; i < n - 1; ++i ) {
        if( s[i] == s[i + 1] && s[i] == 'R' ) ++cnt;

    }
    for( int i = n - 1; i > 0; --i ) {
        if( s[i] == s[i - 1] && s[i] == 'L' ) ++cnt;
    }

    cout << min( n - 1, cnt + k * 2 ) << endl;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int check(int ans,int a[])
{
	while(ans)
	{
		int n = ans%10;
		for (int i = 0; i < 10; ++i)
		{
			if(a[n])
				return true;
		}
		ans/=10;
	}
	return false;
}

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int a[10]={0};
	for (int i = 0; i < k; ++i)
	{
		int no;
		cin>>no;
		a[no]=1;
	}
	int ans=n;
	while(check(ans,a))
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
S=[]
ans=0
import collections
for i in range(n):
    s=input()
    S.append(s)
S=sorted(S)
c=collections.Counter(S)
ANS=[]
for i in range(n-1):
    if (S[i]!=S[i+1] and ans<c[S[i]]) or i==n-2:
        ans=c[S[i]]#Sの？番目がSにいくつあるのか
        ANS.append(ans)
inko=""
ans=max(ANS)
for i in range(n):
    if c[S[i]]==ans and S[i]!=inko:
        print(S[i])
        inko=S[i]

Measured memory_bytes: 38504
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
using namespace std;
int array[51];
int main(){
  int n,p;
  vector<int> v;
  while(cin >>n >>p){
     if(n==0&&p==0){
       break;
     }
     int i=0,gen=p;
     while(true){
       /*
    for(int s=0;s<n;s++){
	 cout << "人" <<s <<" " <<array[s]  <<endl;
       }
       cout <<"p " << p << endl;
       */

       if(p!=0){
       array[i]+=1;
       p--;
        if(array[i]==gen&&p==0){
	  cout   << i <<endl;
	  array[i]=0;
	  break;
	} 
       }else{
	   p+=array[i];
	   array[i]=0;
       }
   
       i++;
    
       if(i==n){
	 i=0;
       }
     }
  }
 
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	ll c;
	cin >> n >> c;
	vector<ll> d(n), v(n);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", &d[i]);
		scanf("%lld", &v[i]);
	}
	ll res = 0;
	vector<ll> mxA(n), mxB(n);
	ll total = 0;
	for (int i = 0; i < n; ++i) {
		total += v[i];
		mxA[i] = total - d[i];
		if (i)
			mxA[i] = max(mxA[i], mxA[i - 1]);
		res = max(res, mxA[i]);
	}
	total = 0;
	for (int i = n - 1; i >= 0; --i) {
		total += v[i];
		mxB[i] = total - (c - d[i]);
		if (i + 1<n)
			mxB[i] = max(mxB[i], mxB[i + 1]);
		res = max(res, mxB[i]);
	}
	total = 0;
	for (int i = 0; i < n; ++i) {
		total += v[i];
		ll cur = total - d[i] * 2;
		if (i + 1 < n)
			cur += mxB[i + 1];
		res = max(res, cur);
	}
	total = 0;
	for (int i = n - 1; i >= 0; --i) {
		total += v[i];
		ll cur = total - (c - d[i]) * 2;
		if (i)
			cur += mxA[i - 1];
		res = max(res, cur);
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

#include <complex>
typedef complex<double> Point;
void update(double& x, double y){
  if(x < y) x = y;
}
int main(){
  int N, K;
  while(cin >> N >> K){
    vector<Point> ps(N);
    vector<double> r(N);
    for(int i = 0; i < N; i++) cin >> ps[i].real() >> ps[i].imag() >> r[i];
    vector<pair<double, double> > seg(N);
    for(int i = 0; i < N; i++){
      double th = asin(r[i] / abs(ps[i]));
      seg[i].first = arg(ps[i]) - th;
      seg[i].second = arg(ps[i]) + th;
      if(seg[i].first < -M_PI){
        seg[i].first += 2 * M_PI;
        seg[i].second = M_PI;
      }else if(seg[i].second < 0){
        seg[i].first = seg[i].second = 0;
      }else{
        seg[i].first = max(seg[i].first, 0.0);
        seg[i].second = min(seg[i].second, M_PI);
      }
    }
    sort(seg.begin(), seg.end());
    vector<double> b, e;
    double cur_max = 0;
    for(int i = 0; i < N; i++){
      if(seg[i].second > cur_max){
        cur_max = seg[i].second;
        b.push_back(seg[i].first);
        e.push_back(seg[i].second);
      }
    }
    int M = b.size();
    static double dp[1510][1510];
    for(int i = 0; i <= M; i++) for(int j = 0; j <= K; j++) dp[i][j] = 0;
    double ans = 0;
    for(int i = 0; i < M; i++){
      int f = i - 1;
      while(f >= 0 && b[i] < e[f]) f--;
      // e[f] < b[i] < e[f + 1] (-1 <= f <= i - 1)
      for(int k = 0; k <= i && k <= K - 1; k++){
        update(dp[i + 1][k + 1], dp[i][k + 1]);
        update(dp[i + 1][k + 1], dp[f + 1][k] + (e[i] - b[i]));
        if(f < i - 1) update(dp[i + 1][k + 1], dp[f + 2][k] + (e[i] - e[f + 1]));
        update(ans, dp[i + 1][k + 1]);
      }
    }
    printf("%.14lf\n", ans / M_PI);
  }
  return 0;
}

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

long long n, m, t, a, c;
unordered_map<long long, long long> cnt;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	cnt[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> c; a += c; a %= m;
		t += cnt[a]; cnt[a]++;
	}
	cout << t;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n;
	cin >> n;
	vector<int> b(n);
	for(int i=0;i<n-1;i++)
		cin >> b[i];
	b[n-1] = 0;
	vector<int> a(n);
	a[0] = b[0];
	for(int i=1;i<n-1;i++) {
		if(b[i] >= b[i-1])
			a[i] = b[i-1];
		else
			a[i] = b[i];
	}
	a[n-1] = b[n-2];
	int sum = 0;
	for(int i=0;i<n;i++) {
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
typedef unsigned long long ll;
#define length 100000   //10万
#define kw_len 10
ll factor[300];
ll memory[300]; 
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num){
    int i = 0,kosuu=0;
    while(*(factor+i) != 0){
        while(num % *(factor+i)==0){
            num /= *(factor+i);
            memory[*(factor+i)] +=1;
        }
        if(num==1)break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろ*/
int elast(ll number){    
    ll tmp=0;
    int flag=0;
    *factor = 2;
    for(int i=3;i <= number;i++){
        flag=0;
        for(int j=0;j <= tmp ;j++){
            if(i % (*(factor+j)) == 0){
                flag=1;
                break;
            }
        }
        if(flag)continue;
        tmp += 1;
        *(factor+tmp) = i;
    }
        return tmp+2;
}

int compare(const int*a,const int *b){
    if(*a<*b)
      return -1;
    else if(*a>*b)
      return 1;
    return 0;
}

ll nCr(int n,int r){
  ll val=1;
  int i;
  if(r==0)return 1;
  for(i=0;i<n-r;i++){
		val *= (n-i);
		val /= (i+1);
	}
  return val;
}

ll nPr(int n,int r){
  ll val=1;
  int i;
  for(i=0;i<r;i++){
    val *= (n-i);
  }
  return val;
}
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/

int num[100000]={0};
char ch[100000];
int main(){
    int N,sum=0,Q,K,i,l,r;
    scanf("%d%d",&N,&Q);
    scanf("%s",ch);
    num[0] =0;
    for(i=1;i<N;i++){
        if(*(ch+i)=='C'&&*(ch+i-1)=='A'){
            sum++;
        }
        *(num+i) = sum; 
    }
    for ( i = 0; i < Q; i++){
        scanf("%d%d",&l,&r);
        printf("%d\n",num[r-1]-num[l-1]);
    }

    return 0;
}


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

using namespace std;

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

const ll mod = 1000000007;
const ll INF = 1000000000000;
string s;
ll ans[100010];

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return pow_mod(x, y - 1) * x % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

int main()
{
	cin >> s;
	ll odd = 0, eve = 0;
	for (int i = 0; i < s.length(); i++)
	{
		swap(odd, eve);
		if (s[i] == 'L')
		{
			ans[i] += eve;
			ans[i - 1] += odd;
			odd = 0, eve = 0;
		}
		else
		{
			eve++;
		}
	}

	for (int i = s.length() - 1; i >= 0; i--)
	{
		swap(odd, eve);
		if (s[i] == 'R')
		{
			ans[i] += eve;
			ans[i + 1] += odd;
			odd = 0, eve = 0;
		}
		else
		{
			eve++;
		}
	}

	for (int i = 0; i < s.length(); i++)
	{
		cout << ans[i];
		if (i == s.length() - 1)
		{
			cout << endl;
		}
		else
		{
			cout << ' ';
		}
	}

	int www;
	cin >> www;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define mp make_pair
#define ft first
#define sd second
#define ue printf("what?\n");
#define pb push_back
#define oo 0x3F3F3F3F	
#define OO 3000000000000000000LL
#define EPS 0
#define maxn 200000
#define pi acos(-1)
#define mod 1000000007
#define mdc __gcd
#define N 100010
#define M 33
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

main()
{
	int a, b, c, ans;
	scanf("%d%d%d", &a, &b, &c);
	ans = abs(b - a) + min(abs(c - b), abs(c - a)); //a -> b -> c
	ans = min(ans, abs(c - a) + min(abs(b - a), abs(b - c))); //a -> c -> b
	ans = min(ans, abs(a - b) + min(abs(c - b), abs(c - a))); //b -> a -> c
	ans = min(ans, abs(c - b) + min(abs(a - b), abs(c - a))); //b -> c -> a
	ans = min(ans, abs(c - a) + min(abs(c - b), abs(b - a))); //c -> a -> b
	ans = min(ans, abs(c - b) + min(abs(c - a), abs(b - a))); //c -> b -> a
	printf("%d\n", ans);
}


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

using namespace std;

int main(){
  int N, tmp_N, sn;
  cin >> N;
  tmp_N = N;
  sn = 0;
  while(tmp_N>0){
    sn += tmp_N % 10;
    tmp_N /= 10;
    //cout << sn << " " << tmp_N << endl;
  }
  if(N % sn==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {

int w,h,x,y,r;

cin >> w >> h >> x >> y >> r;

if( x+r > w || x-r < 0 || y+r > h || y-r <0 )
    cout << "No" << endl;
else cout << "Yes" << endl;

}


Measured memory_bytes: 3104
primes = [2]

def is_prime(num):
    root = num ** 0.5
    for prime in primes:
        if root < prime:
            break
        if num % prime == 0:
            return 0
    return 1

def create_primes(primes, max):
    for i in range(primes[-1] + 1,max):
        if is_prime(i):
            primes += [i]

create_primes(primes, 10000)
count = 0
n = int(input())
s = [int(input()) for _ in range(n)]

print(sum(is_prime(i) for i in s))

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

int main() {
  string S,T;
  cin >>S>>T;
  int s=S.size();
  int t=T.size();
  int N=s-t+1;
  int ANS=0;
  int c=0;
  vector<int>score(N,0);
  vector<int>SCORE(N,0);
  for(int j=0;j<N;j++){
    for(int i=j;i<t+j;i++){
      if(S[i]==T[i-j]){
        score[j]++;
        SCORE[j]++;
      }
    }
  }
  sort(score.begin(),score.end());
  reverse(score.begin(),score.end());
  for(int i=0;i<N;i++){
    if(SCORE[i]==score[0]){
      c=i;
      break;
    }
  }
  for(int i=0;i<t;i++){
    if(S[i+c]!=T[i]){
      ANS++;
    }
  }
  cout<<ANS<<endl;
}

Measured memory_bytes: 3628
n = int(input())

def func(x):
    a = x%10
    b = 0
    while x:
        b = x
        x //= 10
    return (a,b)

freq = {}

for i in range(1, n+1):
    p = func(i)
    freq[p] = freq.get(p, 0) + 1

ans = 0

for i in range(1, n+1):
    p = func(i)
    ans += freq.get((p[1],p[0]), 0)
    
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
struct Edge {
    int d, i, j;
    Edge(int d_, int i_, int j_) : d(d_), i(i_), j(j_) {}
    bool operator< (const Edge& right) const{
        return d > right.d;
    }
};
void calc(int t, vector<vector<pair<int, int > > >& G, vector<int>& distance){
    int new_black = t;
    priority_queue<Edge> temp;
    for (int i = 1; i < G.size(); i++) {
        for (int j = 0; j < G[new_black].size(); j++) {
            if (distance[G[new_black][j].first] != -1) continue;
            int dis = G[new_black][j].second + distance[new_black];
            temp.push(Edge(dis, new_black, G[new_black][j].first));
        }
        while (distance[temp.top().j] != -1) temp.pop();
        distance[temp.top().j] = temp.top().d;
        new_black = temp.top().j;
        temp.pop();
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > G(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        G[u].resize(k);
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            G[u][j] = make_pair(v, c);
        }
    }

    vector<int> distance(n, -1);
    distance[0] = 0;
    calc(0, G, distance);
    for (int i = 0; i < n; i++) {
        cout << i << " " << distance[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 9824
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    vector<int> vec;
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        if(A == 0) {
            int B;
            cin >> B;
            vec.push_back(B);
        }
        else if(A == 1) {
            int B;
            cin >> B;
            cout << vec.at(B) << endl;
        }
        else {
            vec.pop_back();
        }
    }
}


Measured memory_bytes: 4904
#include <iostream>
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);
    long *price = new long[n];
    for(int i = 0; i < n; i++) {
        scanf("%ld", &price[i]);
    }

    long max_profit = -1000000000;
    long min_value = price[0];
    for (int j = 1; j < n; j++)
    {
        max_profit = std::max(max_profit, price[j] - min_value);
        min_value = std::min(min_value, price[j]);
    }

    printf("%ld\n", max_profit);

    return 0;
}


Measured memory_bytes: 4796
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 64

int N;
ull POW[64];
bool BIT[64];
vector<int> MASK[10];

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 63; i++){

		POW[i] = POW[i-1]*2;
	}


	for(int i = 0; i < SIZE; i++){

		BIT[i] = false;
	}

	scanf("%d",&N);

	int num,tmp;
	for(int i = 0; i < N; i++){

		scanf("%d",&num);
		for(int k = 0; k < num; k++){

			scanf("%d",&tmp);
			MASK[i].push_back(tmp);
		}
	}

	int num_query;
	scanf("%d",&num_query);

	int command;
	ull work;
	bool FLG;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&command,&tmp);

		switch(command){
		case 0:

			if(BIT[tmp]){

				printf("1\n");
			}else{

				printf("0\n");
			}
			break;

		case 1:

			for(int i = 0; i < MASK[tmp].size(); i++){

				BIT[MASK[tmp][i]] = true;
			}
			break;

		case 2:

			for(int i = 0; i < MASK[tmp].size(); i++){

				BIT[MASK[tmp][i]] = false;
			}
			break;

		case 3:

			for(int i = 0; i < MASK[tmp].size(); i++){

				BIT[MASK[tmp][i]] = not BIT[MASK[tmp][i]];
			}
			break;

		case 4:

			FLG = true;
			for(int i = 0; i < MASK[tmp].size(); i++){

				if(!BIT[MASK[tmp][i]]){

					FLG = false;
					break;
				}
			}
			if(FLG){

				printf("1\n");
			}else{

				printf("0\n");
			}
			break;

		case 5:

			FLG = false;
			for(int i = 0; i < MASK[tmp].size(); i++){

				if(BIT[MASK[tmp][i]]){

					FLG = true;
					break;
				}
			}
			if(FLG){

				printf("1\n");
			}else{

				printf("0\n");
			}

			break;
		case 6:

			FLG = true;
			for(int i = 0; i < MASK[tmp].size(); i++){

				if(BIT[MASK[tmp][i]]){

					FLG = false;
					break;
				}
			}
			if(FLG){

				printf("1\n");
			}else{

				printf("0\n");
			}
			break;

		case 7:

			num = 0;
			for(int i = 0; i < MASK[tmp].size(); i++){

				if(BIT[MASK[tmp][i]]){

					num++;
				}
			}
			printf("%d\n",num);
			break;

		case 8:

			work = 0;
			for(int i = 0; i < MASK[tmp].size(); i++){

				if(BIT[MASK[tmp][i]]){

					work += POW[MASK[tmp][i]];
				}
			}
			printf("%llu\n",work);

			break;

		default:
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int ans[n];
  rep(i,n) ans[i]=-1;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;
    if(ans[a]==-1){
      ans[a]=b;
    }else if(ans[a]!=b){cout<<"-1"<<endl;return 0;}
  }
  rep(i,n){
    if(ans[i]==-1){
      if(i==0 && i!=n-1) cout<<1;
      else cout<<0;
    }else{
      if(i==0 && ans[i]==0 && i!=n-1){cout<<-1<<endl;return 0;}
      cout<<ans[i];
    }
  }
  cout<<endl;
      

  return 0;
}

Measured memory_bytes: 256