akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

-- main
main :: IO ()
main = cardGameForTwo

cardGameForTwo :: IO ()
cardGameForTwo = do
  n :: Int <- readLn
  as :: [Int] <- getLineSpc
  let ab = zipWith (*) (cycle [1, -1]) $ sortBy (flip compare) as
  print $ sum ab

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

int main() {
  int N;
  cin >> N;
  int64_t L_=2, L__=1;
  int64_t n;
  for (int i=0; i<N; i++) {
    n=L_;
    L_=L__;
    L__=n+L_;
  }
  cout << L_ << endl;
}


Measured memory_bytes: 256
# coding: utf-8

n = int(input())

ans = 0

for i in range(1,n+1): #頂点数の総和を求める
    ans += i*(n-i+1)
    #print(ans)

for _ in range(n-1): #各辺についてu*(n-v+1)を頂点数の総和から引く
    u,v = map(int, input().split())
    if u > v: #上記ではu<vを仮定しているのでu>vのときuとvを入れ替える
        u,v = v,u
    ans -= u*(n-v+1)
    #print(ans)
print(ans)

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

using namespace std;

int main() {
  int a, b, c; cin >> a >> b >> c;
 
  bool f = false;
  for(int i = 0; i < b; i++) {
    if((i * a) % b == c) {
      f = true;
      break;
    }
  }

  if(f) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n;
    cin>>n;
    vector<string> s(n);
    rep(i,0,n-1) cin>>s[i];
    sort(s.begin(),s.end());
    ll cnt = 1;
    rep(i,0,n-2){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 9532
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;

    return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	ll n,x;cin>>n>>x;
	ll l[51];
	l[0]=1;
	for(int i=1;i<=n;i++) l[i]=2*l[i-1]+3;
	ll p[51];
	p[0]=1;
	for(int i=1;i<=n;i++) p[i]=2*p[i-1]+1;
	ll ans=0;
	for(int i=n;i>=0;i--){
		if(i==0) {ans+=1;break;}
		else if(x>(l[i]+1)/2) {ans+=p[i-1]+1;x-=(l[i]+1)/2;}
		else if(x==(l[i]+1)/2) {ans+=p[i-1]+1;break;}
		else if(x>1) x--;
		else if(x==1) break;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

void Solve();

 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}

void Solve(){
  db a,b,x;
    cin>>a>>b>>x;
  db t=(2*a*a*b-2*x)/a/a;
  db ans=a/t;
  if(t>b){
    t=2*x/a/b;
    ans=t/b;
  }
  db pi=3.14159265;
  cout<<90-atanl(ans)*180/pi<<endl;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> G(H);
    rep(i, H) cin >> G.at(i);
    vector<vector<string>> a(H, vector<string>(W));
    rep(i, H) rep(j, W) a.at(i).at(j) = G.at(i).at(j);

    rep(i, H) {
        bool flag = true;
        rep(j, W) if (a.at(i).at(j) == "#") flag = false;
        if (flag) rep(k, W) a.at(i).at(k) = "x";
    }

    rep(j, W) {
        bool flag = true;
        rep(i, H) if (a.at(i).at(j) == "#") flag = false;
        if (flag) rep(l, H) a.at(l).at(j) = "x";
    }

    rep(i, H) {
        bool flag = false;
        rep(j, W) {
            if (a.at(i).at(j) != "x") {
                cout << a.at(i).at(j);
                flag = true;
            }
        }
        if (flag) cout << endl;
    }

}

Measured memory_bytes: 3908
N=int(input())
S=input()
ans=0
tmp=0
for k in range(N):
  for j in range(k):
    i=2*j-k
    if i>=0:
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
        tmp+=1
ans=S.count("R")*S.count("G")*S.count("B")-tmp
print(ans)

      
      
    

Measured memory_bytes: 9120
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

y = -2
ans = 0

for x in a:
    if x == y + 1:
        ans += c[y-1]
    ans += b[x-1]
    y = x

print(ans)

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BQualificationSimulator solver = new BQualificationSimulator();
        solver.solve(1, in, out);
        out.close();
    }

    static class BQualificationSimulator {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            String str = in.next();
            int cnt = 0;
            String[] pass = new String[n];
            int rank = 1;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == 'a') {
                    if (cnt < a + b) {
                        cnt++;
                        pass[i] = "Yes";
                    } else pass[i] = "No";
                } else if (str.charAt(i) == 'b') {
                    if (cnt < a + b && rank <= b) {
                        cnt++;
                        rank++;
                        pass[i] = "Yes";
                    } else pass[i] = "No";
                } else pass[i] = "No";
            }
            for (int i = 0; i < n; i++) {
                out.println(pass[i]);
            }
        }

    }
}



Measured memory_bytes: 26492
#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s="ACL",ans="";
    for(ll i=0;i<n;i++)
    {
        ans+=s;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3592
import math
def prime(x):
        for i in range(2,int(math.sqrt(x))+1):
            if x%i == 0:
                return 0
        return 1

while True:
    a, d, n = map(int, input().split())
    if a==0 and d==0 and n==0:
        break
    
    def A(m):
        return a + (m-1)*d
    
    Plist = []
    i = 1
    while True:
        if A(i)>1 and prime(A(i)):
            Plist.append(A(i))
        i += 1
        if len(Plist)==n:
            break
    
    print(Plist[n-1])


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


int main(){
  int n;
  cin>>n;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
      int f;
      cin>>f;
      v.push_back(f);
  }

  int dp[n];
  dp[n-1]=0;
  dp[n-2]=abs(v[n-2]-v[n-1]);
  for(int i=n-3;i>=0;i--)
  {
      int x=abs(v[i]-v[i+2])+dp[i+2];
      int y=abs(v[i]-v[i+1])+dp[i+1];
      dp[i]=min(x,y);
  }
   cout<<dp[0]<<endl;
}


Measured memory_bytes: 1144
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

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

  cout << s << endl;

  return 0;
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  vec div6(9), div9(9);
  div6[0]=1;
  div9[0]=1;
  rep(i,8){
    div6[i+1] = 6 * div6[i];
    div9[i+1] = 9 * div9[i];
  }

  int ans = 1e8;
  rep(i,n+1){
    int tmp=0;
    int for6=i;
    int for9=n-i;
    int id6=8, id9=8;
    while(for6){
      if(div6[id6]>for6) id6--;
      else {
        for6 -= div6[id6];
        tmp++;
      }
    }
    while(for9){
      if(div9[id9]>for9) id9--;
      else {
        for9 -= div9[id9];
        tmp++;
      }
    }
    chmin(ans, tmp);
  }

  prt(ans);
}


Measured memory_bytes: 3572
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<vector<double>> edge(N);
    for (ll i = 0; i < M; i++) {
        ll s, t;
        cin >> s >> t;
        s--; t--;
        edge[s].push_back(t);
    }

    vector<double> dp(N);
    dp[N - 1] = 0;

    vector<pair<double, ll>> max_diff(N, { 0.0, -1 });
    for (ll i = N - 2; i >= 0; i--) {
        if (edge[i].size() == 1) {
            dp[i] = dp[edge[i].front()] + 1;
            continue;
        }

        for (ll j : edge[i]) {
            dp[i] += 1.0 / edge[i].size() * (1 + dp[j]);
            double diff = (1 + dp[j]);
            if (max_diff[i].first < diff) {
                max_diff[i] = { diff, j };
            }
        }
    }

    //各iで実際に寄与の大きいものを切るとどうなるか
    double ans = N - 1;
    for (ll i = 0; i < N - 1; i++) {
        if (edge[i].size() == 1) {
            continue;
        }
        vector<double> dp2(N);
        dp2[N - 1] = 0;
        for (ll j = N - 2; j >= 0; j--) {
            for (ll k : edge[j]) {
                if (j == i && k == max_diff[j].second) {
                    continue;
                }
                dp2[j] += 1.0 / (edge[j].size() - (j == i)) * (1 + dp2[k]);
            }
        }
        ans = min(ans, dp2[0]);
    }

    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 2560
#include<cstdio>
int n, w[101000], ck[101000], r;
int main() {
	int i;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		if (w[i] == i)ck[i] = 1;
	}
	for (i = 1; i < n; i++) {
		if (ck[i] && ck[i + 1]) {
			ck[i] = ck[i + 1] = 0;
			r++;
		}
	}
	for (i = 1; i <= n; i++)r += ck[i];
	printf("%d\n", r);
}

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

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

ll N;
ll X[100010];
ll Y[100010];
char D[100010];

const ll INF = 1LL << 60;


void calc(ll negv, ll posv, ll stayv, set<ll> & candt){
    if(negv != INF && posv != INF){
        if(posv < negv){
            candt.insert((negv - posv));
        }
    }
    if(negv != INF && stayv != INF){
        if(stayv < negv){
            candt.insert((negv - stayv) * 2);
        }
    }
    if(posv != INF && stayv != INF){
        if(stayv > posv){
            candt.insert((stayv - posv) * 2);
        }
    }
}

int main(){

    cin >> N;
    for(ll i = 0; i < N; i++) cin >> X[i] >> Y[i] >> D[i];

    // ２倍されている点に注意
    set<ll> candt;
    candt.insert(0);

    for(ll ite = 0; ite < 2; ite++){
        set<ll> to_neg, to_pos, stay;
        char negc, posc;
        if(ite == 0){
            negc = 'L';
            posc = 'R';
        }
        else{
            negc = 'D';
            posc = 'U';
        }

        for(ll i = 0; i < N; i++){
            ll v = (ite == 0 ? X[i] : Y[i]);
            if(D[i] == negc){
                to_neg.insert(v);
            }
            else if(D[i] == posc){
                to_pos.insert(v);
            }
            else{
                stay.insert(v);
            }
        }

        // min
        calc(to_neg.size() > 0 ? *to_neg.begin() : INF, 
             to_pos.size() > 0 ? *to_pos.begin() : INF, 
             stay.size() > 0 ? *stay.begin() : INF, 
             candt);
        // max
        calc(to_neg.size() > 0 ? *(--to_neg.end()) : INF, 
             to_pos.size() > 0 ? *(--to_pos.end()) : INF, 
             stay.size() > 0 ? *(--stay.end()) : INF, 
             candt);
    }    

    double ans = INF;

    for(ll t_tmp : candt){
        double t = t_tmp / 2.0;
        double minx = INF;
        double maxx = -INF;
        double miny= INF;
        double maxy= -INF;

        for(ll i = 0; i < N; i++){
            double dx = 0, dy = 0;
            if(D[i] == 'L'){
                dx = -t;
            }
            else if(D[i] == 'R'){
                dx = t;
            }
            else if(D[i] == 'U'){
                dy = t;
            }
            else if(D[i] == 'D'){
                dy = -t;
            }
            minx = min(minx, X[i] + dx);
            maxx = max(maxx, X[i] + dx);
            miny = min(miny, Y[i] + dy);
            maxy = max(maxy, Y[i] + dy);
        }

        ans = min(ans, (maxx - minx) * (maxy - miny));
    }

    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 6272
import math
 
def lcm(a, b):
    return (a*b)//math.gcd(a, b)
 
a, b, c, d = map(int, input().split())
e = lcm(c, d)
 
total = b - (a - 1)
cc = b//c - (a-1)//c
dd = b//d - (a-1)//d
ee = b//e - (a-1)//e
 
ans = total - cc - dd + ee
print(ans)

Measured memory_bytes: 9148
cards = [[0 for i in range(13)] for j in range(4)]
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    if card[0] == 'S':
        suit = 0 
    elif card[0] == 'H':
        suit = 1 
    elif card[0] == 'C':
        suit = 2 
    elif card[0] == 'D':
        suit = 3 
    cards[suit][card[1]-1] = 1 
for i in range(4):
    if i == 0:
        suit = 'S' 
    elif i == 1:
        suit = 'H' 
    elif i == 2:
        suit = 'C' 
    elif i == 3:
        suit = 'D' 
    for j in range(13):
        if not(cards[i][j]):
            print(suit, j+1)

Measured memory_bytes: 7744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define INF 1e9

int main() {
  long long N, L;
  cin >> N >> L;
  
  long long l = L;
  long long r = L + N - 1;
  
  long long eat;
  if (r <= 0) eat = r;
  else if (l >= 0) eat = l;
  else eat = 0;
  
  int answer = (r + l) * N / 2 - eat;
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define pf push_front
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;
 
const int MOD=1e9+7;
const int INF=2e9;
const int magic=348;
const LL LINF=2e16;
const double eps=1e-10;
const int Ni=500000004;
 
inline int getint()
{
	char ch;
	while ((ch=getchar())<'0' || ch>'9') {}
	int res=ch-'0';
	while ((ch=getchar())>='0' && ch<='9') res=res*10+ch-'0';
	return res;
}
 
struct node
{
	LL x,y,z;
};
 
vector<int> v[200048];
vector<node> q[200048];
int deq_num[200048],tot=0;
int n;
 
bool cmp(int x,int y)
{
	return q[deq_num[x]].size()<q[deq_num[y]].size();
}
 
void dfs(int cur)
{
	node ins;int sz=v[cur].size();
	if (sz==0)
	{
		deq_num[cur]=++tot;
		ins.x=ins.y=Ni;ins.z=0;
		q[tot].pb(ins);
		return;
	}
	int i,j,j1,j2,num1,num2,xx,yy,zz;
	for (i=0;i<sz;i++) dfs(v[cur][i]);
	//sort(v[cur].begin(),v[cur].end(),cmp);
	for (i=1;i<sz;i++) if (!cmp(v[cur][i-1],v[cur][i])) swap(v[cur][i-1],v[cur][i]);
	int depth=0;
	for (i=0;i<=sz-2;i++)
	{
		num1=deq_num[v[cur][i]];num2=deq_num[v[cur][sz-1]];
		for (j=0;j<q[num1].size();j++)
		{
			j1=q[num1].size()-1-j;j2=q[num2].size()-1-j;
			depth=max(depth,min(int(q[num1].size()),int(q[num2].size())));
			xx=q[num2][j2].x;yy=q[num2][j2].y;zz=q[num2][j2].z;
			q[num2][j2].x=(xx*q[num1][j1].x)%MOD;
			q[num2][j2].y=((xx*q[num1][j1].y)%MOD+(yy*q[num1][j1].x)%MOD)%MOD;
			q[num2][j2].z=((xx*q[num1][j1].z)%MOD+(yy*q[num1][j1].y)%MOD+(yy*q[num1][j1].z)%MOD+(zz*q[num1][j1].x)%MOD+(zz*q[num1][j1].y)%MOD+(zz*q[num1][j1].z))%MOD;
		}
	}
	deq_num[cur]=deq_num[v[cur][sz-1]];int Num=deq_num[cur],SZ=q[Num].size()-1;
	for (i=0;i<depth;i++)
	{
		q[Num][SZ-i].x=(q[Num][SZ-i].x+q[Num][SZ-i].z)%MOD;
		q[Num][SZ-i].z=0;
	}
	ins.x=ins.y=Ni;ins.z=0;
	q[Num].pb(ins);
}
 
int mypow()
{
	LL res=1;int i;
	for (i=1;i<=n+1;i++) res=(res*2)%MOD;
	return int(res);
}
 
int main ()
{
	int i,x;
	n=getint();
	for (i=1;i<=n;i++)
	{
		x=getint();
		v[x].pb(i);
	}
	dfs(0);
	int Num=deq_num[0];LL ans=0;
	for (i=0;i<q[Num].size();i++) ans=(ans+q[Num][i].y)%MOD;
	ans=(ans*mypow())%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 64752
import java.util.*;

public class Main {

    static final int MOD=1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        char[] str= sc.next().toCharArray();
        int ac[] = new int[n];
        for(int i=0;i<n;i++)ac[i]=0;
        int sum=0;

        for(int i=1;i<n;i++){
            if(str[i-1]=='A'&&str[i]=='C'){
                sum++;
            }
            ac[i]=sum;
        }
        ac[n-1]=sum;

        //for(Integer a:ac) System.out.println(a);


        for(int i=0;i<q;i++){
            int l = sc.nextInt()-1;
            int r = sc.nextInt()-1;
            System.out.println(ac[r]-ac[l]);
        }
        

    }
}


Measured memory_bytes: 79960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll>t(n);
    for(ll i=0;i<n;i++) cin >> t[i];
    sort(t.begin(),t.end());
    ll ans=0;
    ll i=0;
    while(i<n){
        i++;
        ll cnt=1,time=0;
        while(cnt<c&&time<=k){
            if(time+t[i]-t[i-1]>k) break;
            time+=t[i]-t[i-1];
            cnt++;
            i++;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4024
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll a,b;
    std::cin >> a>>b;
    if( (a+b)%2==0 ){
        std::cout << (a+b)/2 << std::endl;
    }else{
        std::cout << "IMPOSSIBLE" << std::endl;
    }
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

long long inv(int a, int p) { return a==1 ? 1 : (1-p*inv(p%a,a))/a+p; }
static const int MODVAL = 1000000007;
struct mint {
  int val;
  mint():val(0){}
  mint(int x):val(x%MODVAL) {}
  mint(size_t x):val(x%MODVAL) {}
  mint(long long x):val(x%MODVAL) {}
  mint& operator+=(mint y) { val+=y.val; if(val>=MODVAL) val-=MODVAL; return *this; }
  mint& operator-=(mint y) { val-=y.val; if(val<0) val+= MODVAL; return *this; }
  mint& operator*=(mint y) { val=(val*(long long)y.val)%MODVAL; return *this; }
  mint& operator/=(mint y) { val=(val*inv(y.val,MODVAL))%MODVAL; return *this; }
};
inline mint operator+(mint x, mint y) { return x+=y; }
inline mint operator-(mint x, mint y) { return x-=y; }
inline mint operator*(mint x, mint y) { return x*=y; }
inline mint operator/(mint x, mint y) { return x/=y; }
mint POW(mint x, long long n) { mint r(1); for(;n;x*=x,n>>=1) if(n&1) r*=x; return r; }
mint FAC(int n) { static vector<mint> FAC_(1,1);
  while(int(FAC_.size())<=n) FAC_.push_back(FAC_.back()*FAC_.size()); return FAC_[n]; }
inline mint CMB(int n, int k) { return k<0||n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }
inline ostream& operator<<(ostream& os, mint a) { return os << a.val; }

char buf[100000+5];
bool visited[100005][2];
mint memo[100005][2];
int n;

mint solve(int pos, int eq) {
  mint &res = memo[pos][eq];
  if(!visited[pos][eq]) {
    visited[pos][eq] = true;
    if(pos == n) {
      res = 1;
    } else {
      res = 0;
      // to 0
      res += solve(pos+1, eq && 0 == buf[pos]-'0');
      // to 1
      if(!eq || buf[pos]-'0' == 1) {
        res += solve(pos+1, eq && 1 == buf[pos]-'0') * 2;
      }
    }
    // cerr << "> " << pos << " " << eq << " : " << res << endl;
  }
  return res;
}

int main(void) {
  scanf("%s", buf);
  n = strlen(buf);
  cout << solve(0, true) << endl;
  
  return 0;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
    int N, K, A[MAX];
    cin >> N >> K;
    int maxi = 0;
    int gcd = A[0];
    rep(i, N) {
        cin >> A[i];
        maxi = max(maxi, A[i]);
        gcd = __gcd(gcd, A[i]);
    }

    if (K <= maxi && K % gcd == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 640
#include <stdio.h>

int main (void) {
  long long int x;
  long long int y;
  scanf("%lld%lld", &x, &y);

  long long int i=x;
  int j=0;
  while (i<=y) {
    i=i*2;
    j++;
  }
  
  printf("%d\n", j);

  return 0;
}

Measured memory_bytes: 128
/* A - Takahashikun, The Strider */

#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b){
  int r;
  r = a % b;
  if(r == 0) return b;
  else return gcd(b, r);
}

int main(){
  int X, G;
  cin >> X;
  G = gcd(X, 360);
  cout << 360 / G << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int a=0,b=0;
  cin>>s;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A')
      a++;
    
    if(s[i]=='B')
      b++;
  }
  if(a==3 || b==3)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<int> L(N);//iばんめまでの最大公約数
    vector<int> R(N);//逆
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    for(int i=0;i<N;i++){
        if(i==0){
            L.at(0)=A.at(0);
        }
        else{
            L.at(i)=gcd(A.at(i),L.at(i-1));
        }
        //cout<<i<<" "<<L.at(i)<<endl;
    }
    for(int i=N-1;i>=0;i--){
        if(i==N-1){
            R.at(N-1)=A.at(N-1);
        }
        else{
            R.at(i)=gcd(A.at(i),R.at(i+1));
        }
        //cout<<i<<" "<<R.at(i)<<endl;
    }
    int answer=1;
    for(int i=0;i<N;i++){
        if(i==0){
            answer=max(answer,R.at(1));
        }
        else if(i==N-1){
            answer=max(answer,L.at(N-2));
        }
        else{
            answer=max(answer,gcd(R.at(i+1),L.at(i-1)));
        }
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 4568
using System;

public class Dice
{
	private int[] labels;
	public const int TOP = 0;
	public const int FRONT = 1;
	public const int RIGHT = 2;
	public const int LEFT = 3;
	public const int BACK = 4;
	public const int BOTTOM = 5;
	public Dice( int[] labels )
	{
		this.labels = labels;
	}
	public void roll( string cmds )
	{
		int t;
		for( int i=0; i<cmds.Length; i++ ) {
			if( 'E' == cmds[i] ) {
			t = this.labels[TOP];
				this.labels[TOP] = this.labels[LEFT];
				this.labels[LEFT] = this.labels[BOTTOM];
				this.labels[BOTTOM] = this.labels[RIGHT];
				this.labels[RIGHT] = t;
			} else if( 'S' == cmds[i] ) {
				t = this.labels[TOP];
				this.labels[TOP] = this.labels[BACK];
				this.labels[BACK] = this.labels[BOTTOM];
				this.labels[BOTTOM] = this.labels[FRONT];
				this.labels[FRONT] = t;
			} else if( 'W' == cmds[i] ) {
				t = this.labels[TOP];
				this.labels[TOP] = this.labels[RIGHT];
				this.labels[RIGHT] = this.labels[BOTTOM];
				this.labels[BOTTOM] = this.labels[LEFT];
				this.labels[LEFT] = t;
			} else if( 'N' == cmds[i] ) {
				t = this.labels[TOP];
				this.labels[TOP] = this.labels[FRONT];
				this.labels[FRONT] = this.labels[BOTTOM];
				this.labels[BOTTOM] = this.labels[BACK];
				this.labels[BACK] = t;        
			} else if( 'M' == cmds[i] ) {
				t = this.labels[FRONT];
				this.labels[FRONT] = this.labels[RIGHT];
				this.labels[RIGHT] = this.labels[BACK];
				this.labels[BACK] = this.labels[LEFT];
				this.labels[LEFT] = t;        
			}	
		}
	}
	public int getLabel( int face )
	{
		return this.labels[face];
	}
}

public class Test
{
	public static void Main( )
	{

		int[] labels = Array.ConvertAll( Console.ReadLine().Split( ' ' ), int.Parse );
		Dice dice = new Dice( labels );
		int q = int.Parse( Console.ReadLine() );
		string cmds = "SWWWSMMM";
		for( int i=0; i<q; i++ ) {
			int[] tf = Array.ConvertAll( Console.ReadLine().Split( ' ' ), int.Parse );
			for( int j=0; j<5; j++ ) {
				if( tf[0] == dice.getLabel( Dice.TOP ) ) { break; }
				dice.roll( cmds[j].ToString() );			
			}
			for( int j=5; j<8; j++ ) {
				if( tf[1] == dice.getLabel( Dice.FRONT ) ) { break; }
				dice.roll( cmds[j].ToString() );			
			}
			Console.WriteLine( dice.getLabel( Dice.RIGHT ) );
		}		
	}
}

Measured memory_bytes: 9124
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#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 << '\n'; }
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__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e6 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    string s ;
    cin >> s ; 
    if ( s[2] == s[3] && s[4] == s[5] ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    
    if(a%3==0) {
        cout << "Possible" << endl;
    }
    else if(b%3==0) {
        cout << "Possible" << endl;
    }
    else if((a+b)%3==0) {
        cout << "Possible" << endl;
    }
    else {cout << "Impossible" << endl;}
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int partition(int *,int,int);
void swap(int *,int *);

int main(){
  int i,q,A[N],n,p=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  q=partition(A,p,n-1);
  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");
  return 0;
}
int partition(int A[],int p,int r){
  int x,i,j;
  x = A[r];
  i = p-1;
  for (j=p;j<r;j++){
    if (A[j] <= x){
      i = i+1;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}
void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}



Measured memory_bytes: 2096
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int K, S;
    cin >> K >> S;

    int count = 0;

    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            if ((S - i - j <= K) && (S - i - j >= 0))
                count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a=0,c=s.size();
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0')
      a++;
  }
  cout << 2*min(a,c-a) << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>

using namespace std;

int main()
{
    int N;
    scanf("%d\n", &N);
    long long T, A;
    for (int i = 0; i < N; ++i){
        int Ti, Ai;
        scanf("%d %d\n", &Ti, &Ai);
        if (i == 0){
            T = Ti;
            A = Ai;
        }else{
            const long long n = max(((Ti > 0) ? T / Ti + ((T % Ti) ? 1 : 0) : 0), ((Ai > 0) ? A / Ai + ((A % Ai) ? 1 : 0) : 0));
            T = n * Ti;
            A = n * Ai;
        }
    }
    printf("%lld\n", T + A);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl t(5);
  rep(i, 5) cin >> t[i];
  sort(all(t));
  ll g = (n + t[0] - 1) / t[0];
  cout << g + 4 << endl;
}

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

int main() {
  vector<int> cnt(10, 0);
  for (int i = 0; i < 4; i++) {
    int N; cin >> N;
    cnt.at(N)++;
  }
  if (cnt.at(1) > 0 && cnt.at(9) > 0 && cnt.at(7) > 0 && cnt.at(4) > 0) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    char a,b; cin>>a>>b;
    if(a=='9'||b=='9')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int dp[110000];

int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           vin h(n);
           rep(i,0,n)cin>>h[i];
           rep(i,0,n)dp[i]=inf;
           dp[0]=0;
           rep(i,0,n){
            if(i-1>=0)chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
            if(i-2>=0)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
           }
           cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 3952
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  auto f = false;
  foreach (i; 0..s.length-1) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      f = true;
      break;
    }
  }
  if (f) writeln("Yes");
  else writeln("No");
}


Measured memory_bytes: 256
L, R = map(int, input().split())
mod = 2019
mini = 2019 #最大値2019
count1 = 0

for i in range(L,R):
    count2 = 0
    for j in range(i+1, R+1):
        #if i == 3 and j == 673:
        #    print(i, j)
        #    print(i%mod,j%mod,(i % mod) * (j % mod))
        if mini > (((i % mod) * (j % mod)))%mod:
            mini = (((i % mod) * (j % mod))%mod)
        count2 += 1
        if count2 == mod:
            break
    count1 += 1
    if count1 == mod:
        break
print(mini)
    

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

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

LL powe(LL a, LL b) {
  LL r = 1;
  while (b) {
    if (b&1) {
      (r *= a) %= MOD;
    }
    a = a * a % MOD;
    b >>= 1;
  }
  return r;
}

int H[105];
// ababababab..., any
pair<LL, LL> go(int a, int b, int offset) {
  // printf("%d %d %d\n", a, b, offset);

  if (a == b) return { 1, 1 };

  int mini = 1e9;
  FOR(i,a,b) mini = min(mini, H[i] - offset);
  if (mini == 0) return {1, 1};
  // assert(mini > 0);

  if (a + 1 == b) return { powe(2, mini-1), powe(2, mini) };

  int S = a;

  LL aba = 1, any = 1, aba_counted = 1;
  int minis = 0;
  FOR(i,a,b+1) {
    if (i == b || H[i]-offset == mini) {
      if (i > S) {
        auto rec = go(S, i, offset+mini);

        (aba *= 2 * rec.st) %= MOD;
        (any *= (rec.nd + 2 * rec.st)) %= MOD;
      }

      S = i + 1;

      if (i < b) {
        (any *= 2) %= MOD;
        ++minis;
      }
    }
  }

  // printf("%d %d %d %lld %lld(%d %lld)\n", a, b, offset, aba, any, mini, powe(2, mini)-2);
  (any += 2 * aba * (powe(2, mini-1)-1)) %= MOD;
  (aba *= powe(2, mini-1)) %= MOD;
  // printf("%d %d %d %lld %lld\n", a, b, offset, aba, any);

  return {aba, any};
}

int main() {
  // ios_base::sync_with_stdio(0);

  int N;
  scanf("%d", &N);
  REP(i,N) {
    scanf("%d", &H[i]);
  }

  LL any = 0;
  REP(i,N) {
    int h = 0;
    if (i > 0) h = max(h, H[i-1]);
    if (i < N-1) h = max(h, H[i+1]);
    h = min(h, H[i]);
    any += H[i] - h;
    H[i] = h;
  }

  LL result = powe(2, any);
  auto r = go(0, N, 0);
  (result *= r.nd) %= MOD;

  /*
  REP(i,N) {
    if (H[i] == 1) {
      ++any;
      (result *= go(S,i)) %= MOD;
      S = i + 1;
    }
  }

  (result *= powe(2, any)) %= MOD;
  */

  printf("%lld\n", result);
}


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

using namespace std;

string S;
bool used[26];

int main(void)
{
cin >> S;

for(int i = 0; i < (int)S.size(); i++){
used[S[i] - 'a'] = true;
}

int ans = 0;
for(; ans < 26; ans++){
if(!used[ans]) break;
}

if(ans == 26) cout << "None" << endl;
else cout << (char)(ans + 'a') << endl;

return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;string s;cin>>n>>s;
  for(int i=0;i<s.size();i++){
    char c=s[i];
    c+=n;
    if(c>'Z')c-=26;
    cout<<c;
  }
  cout<<endl;

  return 0;
}


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

const int N = 3e5 + 9;

struct DSU {
	vector<int> par, rnk, sz, ed; int c;
	DSU(int n) : par(n + 1), rnk(n + 1,0), sz(n + 1,1), ed(n + 1, 0), c(n) {
		for (int i = 1; i <= n; ++i) par[i] = i;
	}
	int find(int i) { return (par[i] == i ? i : (par[i] = find(par[i]))); }
	bool same(int i, int j) { return find(i) == find(j); }
	int get_size(int i) { return sz[find(i)]; }
	int count() { return c; } //connected components
	int edge_count(int i) {return ed[find(i)]; }
	int merge(int i, int j) {
		if ((i = find(i)) == (j = find(j))) {
			ed[i] ++;
			return -1; 
		}
		else --c;
		if (rnk[i] > rnk[j]) swap(i, j);
		par[i] = j; sz[j] += sz[i], ed[j] += ed[i] + 1;
		if (rnk[i] == rnk[j]) rnk[j]++;
		return j;
	}
};

map<int, int> mp;
int get_id(int k) {
	if (mp.find(k) != mp.end()) return mp[k];
	int z = mp.size() + 1;
	return mp[k] = z;
}
int a[N], b[N];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i], a[n + 1] ^= a[i];
	for (int i = 1; i <= n; i++) cin >> b[i], b[n + 1] ^= b[i];
	n++;
	// you can swap (a[i], a[n])
	// find the minimum number of swaps to tranform a to b
	vector<int> va, vb;
	for (int i = 1; i <= n; i++) va.push_back(a[i]);
	for (int i = 1; i <= n; i++) vb.push_back(b[i]);
	sort(va.begin(), va.end());
	sort(vb.begin(), vb.end());
	if (va != vb) return cout << -1 << '\n', 0;
	for (int i = 1; i <= n; i++) a[i] = get_id(a[i]);
	for (int i = 1; i <= n; i++) b[i] = get_id(b[i]);
	DSU d(n);
	for (int i = 1; i <= n; i++) {
		if (a[i] != b[i]) {
			d.merge(a[i], b[i]);
		}
	}
	int p = d.find(a[n]);
	set<int> se;
	for (int i = 1; i <= n; i++) {
		se.insert(d.find(i));
	}
	int ans = 0;
	for (auto u: se) {
		int e = d.edge_count(u);
		if (e) {
			if (u == p) {
				if (a[n] == b[n]) ans += e;
				else ans += e - 1;
			}
			else ans += e + 1;
		}
	}
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 15628
#!/usr/bin/env python3

while True:
	n,m = map(int,input().split())

	if n == 0 and m == 0:
		break

	sum = []

	for i in range(m):
		sum.append(0)

	smax = 0

	for i in range(n):
		ans = list(map(int,input().split()))
		for i in range(m):
			if ans[i] == 1:
				sum[i] += 1
			if smax < sum[i]:
				smax = sum[i]

	ans = ""

	for i in reversed(range(smax+1)):
		for j in range(m):
			if sum[j] == i:
				ans += str(j+1) + " "

	ans = ans.rstrip(" ")
	print(ans)

Measured memory_bytes: 7572
def readinput():
    s=input()
    return s

def main(s):
    
    maxlen=0
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            sub=s[i:j]
            for c in sub:
                if(c == 'A' or c == 'C' or c == 'G' or c == 'T'):
                    pass
                else:
                    break
            else:
                maxlen=max(maxlen,len(sub))
        
    return maxlen

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

ll gcd(ll a,ll b) {
    if (b == 0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b) {
    return a / gcd(a,b) * b;
}

int main (void) {
    int N;
    cin>>N;
    vector<ll> A(N);
    vector<ll> lgcd(N+1,A[0]),rgcd(N+1,A[N-1]);
    REP(i,N) cin>>A[i];
    REP(i,N) {
        lgcd[i + 1] = gcd(lgcd[i],A[i]);
    }
    for (int i = N-1 ; i >=  0 ; i--) {
        rgcd[i] = gcd(rgcd[i+1],A[i]);
    }
    ll ans = 1;
    REP(i,N) {
        ll temp = gcd(lgcd[i], rgcd[i+1]);
        ans = max(ans,temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <complex>
#include <cstdio>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;

double dot(point a,point b){
  return a.x*b.x+a.y*b.y;
}

double cross(point a,point b){
  return a.x*b.y-a.y*b.x;
}

point projection(point a,point b,point c){
  point base = b - a;
  double r = dot(c-a,base)/(abs(base)*abs(base));
  return a+base*r;
}

point reflection(point a,point b,point c){
  return 2.0*projection(a,b,c)-c;
}

int main(){
  point a,b,c,d;
  int q;
  cin >> q;
  for(int i=0;i<q;i++) {
    cin >>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
    int ans = 0;
    if(dot(a-b,c-d)==0) ans = 1;
    if(cross(a-b,c-d)==0) ans = 2;
    cout << ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1232