akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = input()
res = False
for i in n:
    if i == '7':
        res = True
print('Yes' if res else 'No')

Measured memory_bytes: 10444
#include <bits/stdc++.h>
    
using namespace std;
    
int main(){
    int a, b;
    cin >> a >> b;
    
    for(int i = 1 ; i <= 3 ; i++){
        if((a * b * i) & 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No\n";
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 3005
ll dp[ma][ma][4],n,m;
int a[ma][ma];

ll cal(ll x,ll y,ll f)
{
    if(x==n&&y==m)
    {
        if(f<3)return a[x][y];
        return 0;
    }
    ll &r=dp[x][y][f];
    if(r!=-1)return r;
    r=0;
    if(y<m)
    {
        ll r1=cal(x,y+1,f);
        r=max(r,r1);
        if(f<3&&a[x][y])
        {
            r1=cal(x,y+1,f+1)+a[x][y];
            r=max(r,r1);
        }
    }

    if(x<n)
    {
        ll r1=cal(x+1,y,0);r=max(r,r1);
        if(f<3&&a[x][y])
        {
            r1=cal(x+1,y,0)+a[x][y];
            r=max(r,r1);
        }
    }
    return r;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll i,j,k;
    while(cin>>n>>m>>k)
    {
       memset(dp,-1,sizeof(dp));
       for(i=1;i<=k;i++)
       {
           ll x,y,c;
           cin>>x>>y>>c;
           a[x][y]=c;
       }
       ll ans=cal(1,1,0);
       cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 321372
N, A, B, C, D = map(int, input().split())
A, B, C, D = A-1, B-1, C-1, D-1
S = input() + "###"
def chk(l, r):
    for i in range(l, r-1):
        if S[i:i+2] == "##":
            return 0
    return 1

def chk3(l, r):
    for i in range(l, r):
        if S[i:i+3].count("#") == 0:
            return 1
    return 0

if chk(A, C) and chk(B, D) and (C < D or chk3(B-1, D)):
    print("Yes")
else:
    print("No")


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

const int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  mint sum = 0;
  rep(i, n) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  mint ans = 0;
  rep(i, n - 1) {
    sum -= a.at(i);
    ans += sum * a.at(i);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <set>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int n, total = 0, ok = 0;
    string output = "No";
    cin >> n;
    if(n <= 3) output = "No";
    else {
        for (int i = 0; i < (n / 7 + 1); i++) {
            total = i * 7;
            if(total == n){
                output = "Yes";
                break;
            }
            for(int j = 0; j < (n / 4 + 1); j++){
                total += 4;
                if(total == n){
                    output = "Yes";
                    ok = 1;
                    break;
                }
            }
            if(ok == 1) break;
        }
    }
    cout << output << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int n, k;

int main() {

	cin >> n;

	if (n == 1)
	{
		cout << "Yes" << endl;
		cout << 2 << endl;
		cout << "1 1" << endl;
		cout << "1 1" << endl;
		return 0;
	}

	if (n < 3)
	{
		cout << "No" << endl;
		return 0;
	}

	k = -1;
	int tmp = sqrt(2 * n) + 1;
	if (tmp * (tmp-1) == 2 * n)
		k = tmp;
	else
		if (tmp * (tmp+1) == 2 * n)
			k = tmp+1;

	if (k == -1)
	{
		cout << "No" << endl;
		return 0;
	}

	vector<vector<long long> > res(k, vector<long long>(k-1));

	long long num = 1;
	for (int i = 0; i < k; ++i)
		for (int j = i; j < k-1; ++j)
		{
			res[i][j] = num;
			++num;
		}

	for (int i = 1; i < k; ++i)
		for (int j = 0; j < i; ++j)
			res[i][j] = res[j][i-1];

	cout << "Yes" << endl;
	cout << k << endl;
	for (int i = 0; i < k; ++i)
	{
		cout << k-1 << " ";
		for (int j = 0; j < k-2; ++j)
			cout << res[i][j] << " ";
		
		cout << res[i][k-2] << endl;

	}

	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;

	vector<int> h(n);
	int mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		mx = max(mx, h[i]);
	}

	bool st = false;
	int ans = 0;
	for (int i = 0; i < mx; i++) {
		st = false;
		for (int j = 0; j < n; j++) {
			if (h[j] > 0) {
				if (!st) {
					st = true;
					ans++;
				}
				h[j]--;
			} else {
				st = false;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();

        if (S == T.Substring(0, T.Length - 1))
        Console.WriteLine("Yes");
        else
        Console.WriteLine("No");
    }

}

Measured memory_bytes: 25792
import java.util.*;
public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
        int line = sc.nextInt();
switch (line % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        System.out.println("hon");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        System.out.println("pon");
        break;
    case 3:
        System.out.println("bon");
        break;
    default:
        break;
}
    }
}

Measured memory_bytes: 27044
from collections import defaultdict
from bisect import bisect_right
s,t=input(),input()
m=len(s)

dictionary=defaultdict(list)
for i,j in enumerate(s):
    dictionary[j] +=[i+1]

index,ans=0,0
for i in t:
    try:
        point=bisect_right(dictionary[i],index)
        if point==len(dictionary[i]):num=dictionary[i][0]
        else:num=dictionary[i][point]

        if index>=num:
            ans +=m
        index=num
    except:print(-1);exit()

print(ans+index)

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

int main(){
  string S,T;
  cin >> S >> T;
  
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  vector<int> vec(5);
  int cnt=0;
  rep(i,5){
    cin>>vec[i];
    int a=(vec[i]+9)/10*10;
    cnt+=a;
  }
  int ans=cnt;
  rep(i,5){
    int b=vec[i];
    b%=10;
    if(b!=0)ans=min(ans,cnt+b-10);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define pb push_back
#define rep(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define inf 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<ll, p> tp;
typedef pair<string, string> ps;

ll n, dp[40][40][40][130];
char l[] = {'A', 'C', 'T', 'G'};

ll DP(ll num, char mitu, char futa, char hito) {
  if (num == n) {
    return 1;
  }
  if (dp[mitu - 'A'][futa - 'A'][hito - 'A'][num]) {
    return dp[mitu - 'A'][futa - 'A'][hito - 'A'][num];
  }
  ll ans = 0;
  for (auto &c : l) {
    if (c == 'C') {
      if (futa == 'A' && hito == 'G') {
        continue;
      }
      if (futa == 'G' && hito == 'A') {
        continue;
      }
      if (mitu == 'A' && futa == 'G')
        continue;
      if (mitu == 'A' && hito == 'G')
        continue;
    }
    if (c == 'G') {
      if (futa == 'A' && hito == 'C') {
        continue;
      }
    }
    ans += DP(num + 1, futa, hito, c);
  }
  return dp[mitu - 'A'][futa - 'A'][hito - 'A'][num] = ans % MOD;
}
int main() {
  cin >> n;
  cout << (DP(2, 'F', 'A', 'G') + DP(2, 'F', 'G', 'A') + DP(2, 'F', 'A', 'C') +
           DP(2, 'F', 'C', 'A') + DP(2, 'F', 'A', 'T') + DP(2, 'F', 'T', 'A') +
           DP(2, 'F', 'C', 'T') + DP(2, 'F', 'T', 'C') + DP(2, 'F', 'C', 'G') +
           DP(2, 'F', 'G', 'C') + DP(2, 'F', 'T', 'G') + DP(2, 'F', 'G', 'T') +
           DP(2, 'F', 'A', 'A') + DP(2, 'F', 'C', 'C') + DP(2, 'F', 'T', 'T') +
           DP(2, 'F', 'G', 'G')) %
              MOD
       << endl;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
int h,n;
int dp[1001][100100];
int a[4000],b[4000];

int go(int i,int sum){

         if(i>n) return 1e9;
         if(sum<=0) return 0;
        if(dp[i][sum]!=-1) return dp[i][sum];
       dp[i][sum] =min(b[i]+go(i,sum-a[i]),go(i+1,sum));
       return dp[i][sum];
}
 int main()
{

       cin >> h >> n;

     for(int i = 1; i<=n; i++){
        cin >> a[i] >> b[i];
     }
     memset(dp,-1,sizeof dp);
     cout << go(1,h) << '\n';

   return 0;
}


Measured memory_bytes: 392448
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextInt();
		System.out.println(fact(n));
	}
	static long fact(long n){
		if(n==0){
			return 1;
		}else{
			return n*fact(n-1);
		}
	}
}

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n*(n+1))/2)%M; }
inline ll sum_2(const ll n) { return ((n*(n+1)*(2*n+1))/6)%M;}
inline ll sum_3(const ll n) { return (((n*(n+1))/2)%M * ((n*(n+1))/2)%M)%M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j)-sum_1(i-1)+M)%M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j)-sum_2(i-1)+M)%M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j)-sum_3(i-1)+M)%M; }

void solve() {
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    // for (ll i = k; i <= n+1; ++i) {
    //     // auto min_t = (i*(i+1))/2;
    //     // auto max_t = (i*(2*n+3 - i))/2;
    //     // ans = ans + (max_t - min_t + 1)%M;
    //     // ans %= M;
    //     /**
    //      Sum(i*(2*n+3-i) - i*(i+1)) from k to n+1
    //      Sum 2 *((n+1)*i - i*i)
    //      Sum 2 [i*(n+1) - i*i] from k....n+1
    //     */
    // }
    ans =  ((n+1)%M * sum_1(k,n+1) - sum_2(k,n+1) + M)%M + n+2-k; 
    cout << ans%M;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ld r;
  cin >> r;

  cout << 2 * r * M_PI << '\n';




  
  return 0;
}

Measured memory_bytes: 3804
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
#define endl "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e12;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {int operator()(int x) const { return x ^ RANDOM; }};
string toString(long long x){stringstream ss;ss << x;string str = ss.str();return str;}
long long fastpow(long long x,long long k){if(!k)return 1;if(k & 1)return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
long long ans = fastpow(x,k/2);ans %= MOD;ans *= ans;ans %= MOD;return ans;}
long long sumF(long long x){int s = 0;while(x)s += x%10,x /= 10;return s;}
bool isS(char c){return (c >= 'a' && c <= 'z');}
bool isB(char c){return (c >= 'A' && c <= 'Z');}
bool isD(char c){return (c >= '0' && c <= '9');}
bool isSqrt(long long x){ long long f = sqrt((long double)x + 0.5); return f*f == x;}
bool isCubic(long long x) {long long f = cbrt((long double)x + 0.5); return f*f*f == x;}
long long lcm(long long a,long long b){return a * (b / __gcd(a,b));}
vector<long long> divVec(long long x){vector<long long> tmp;for(long long i = 1;1LL*i*i <= x;i++){if(x % i == 0){tmp.push_back(i);if(x / i != i)
tmp.push_back(x / i);}sort(tmp.begin(),tmp.end());}return tmp;}
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
int primeFactors(long long n)
{
    int ret = 0;
    if(n % 2 == 0)
        ret++;
    while (n % 2 == 0)
    {

        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        if(n % i == 0)
            ret++;
        while (n % i == 0)
        {
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ret++;

    return ret;
}
int32_t main() {
   // freopen("output.txt","w",stdout);
    long long a,b;
    cin >> a >> b;
    cout << primeFactors(__gcd(a,b))+1;
}


Measured memory_bytes: 256
import math

a, b, water = map(int, input().split())
pool = a ** 2 * b

if water == pool:
    ans = 0
elif water > pool / 2:
    high = 2 * (pool - water) / (a ** 2)
    ans = 90 - math.degrees(math.atan(a / high))
elif water == pool / 2:
    ans = 45
else:
    high = 2 * water / (a * b)
    ans = 90 - math.degrees(math.atan(high / b))

print(ans)

Measured memory_bytes: 3060
import collections
from operator import mul
from functools import reduce


def cmb(n, r):
    if n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n = int(input())
    s_list = []
    for i in range(n):
        temp_s = sorted(list(input()))
        s_list.append(''.join(temp_s))

    counter = collections.Counter(s_list)
    ans = 0
    for key, value in counter.items():
        temp = cmb(value, 2)
        ans += temp


    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20016
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		boolean[] nswe = new boolean[4];
		char[] S = sc.next().toCharArray();
		for(char c : S){
			if(c == 'N') nswe[0] = true;
			else if(c == 'S') nswe[1] = true;
			else if(c == 'W') nswe[2] = true;
			else if(c == 'E') nswe[3] = true;
		}
		System.out.println((nswe[0] == nswe[1] && nswe[2] == nswe[3]) ? "Yes" : "No");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#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<int,pii> piii;
#define mp make_pair
signed main(){
    int h,w;cin>>h>>w;
    vector<vector<int>>dp(10,vector<int>(10,INF));
    rep(i,10)rep(j,10)cin>>dp[i][j];
    rep(k,10)rep(i,10)rep(j,10)cmin(dp[i][j],dp[i][k]+dp[k][j]);
    int ans=0;
    rep(i,h)rep(j,w){
        int temp; cin>>temp;
        if(temp==-1||temp==1)continue;
        ans+=dp[temp][1];
    }
    cout<<ans<<endl;
    
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int x, y, a, b, c; std::cin >> x >> y >> a >> b >> c;
  vi p(a), q(b), r(c);
  rep(i, a) std::cin >> p[i];
  rep(i, b) std::cin >> q[i];
  rep(i, c) std::cin >> r[i];
  sort(rrng(p)), sort(rrng(q));
  rep(i, x) r.pb(p[i]);
  rep(i, y) r.pb(q[i]);
  sort(rrng(r));
  ll ans = 0;
  rep(i, x+y) {
    ans += r[i];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
using namespace std;
int n;
set<string> tbl;
bool conv(char s[30],char t[30]){
  bool used[26]={};
  for(int i=0;i<n;++i){
    int c = s[i]-'a';
    if(!used[c] && c){
      used[c]=true;
      if(s[i]-1!=t[i]) return false;
    }
    else if(s[i]!=t[i]) return false;
  }
  return true;
}
int main(){
  //  string s;
  char s[30];
  while(cin>>s,s[0]!='#'){
    tbl.clear();
    n=strlen(s);
    vector<string> ans;
    for(int i=0;i<1<<n;++i){
      char t[30];
      for(int j=0;j<n;++j){
	if((i>>j)&1 && s[j]<'z')
	  t[j]=s[j]+1;
	else t[j]=s[j];
      }
      if(conv(t,s)) tbl.insert(string(t,n));
    }

    for(set<string>::iterator it=tbl.begin();it!=tbl.end();++it) ans.push_back((*it));
    int m = ans.size();
    cout << m << endl;
    if(m<=10){
      for(int i=0;i<m;++i) cout << ans[i] << endl;
    }
    else{
      for(int i=0;i<5;++i) cout << ans[i] << endl;
      for(int i=m-5;i<m;++i) cout << ans[i] << endl;
    }
  }
  return 0;
}

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

int c[16], x[20001];
int dp[20001][256];
int d(int a) {
	if (a < 0)return 0;
	if (a > 255)return 255;
	return a;
}
int diff(int i, int a) {
	return (x[i] - a)*(x[i] - a);
}
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, m)scanf("%d", &c[i]);
		rep(i, n)scanf("%d", &x[i]);
		memset(dp, 0x3f, sizeof(dp));
		dp[0][128] = 0;
		rep(i, n)rep(j, 256) {
			if (dp[i][j] == INF)continue;
			rep(k, m) {
				int a = d(j + c[k]);
				dp[i + 1][a] = min(dp[i + 1][a], dp[i][j] + diff(i, a));
			}
		}
		int Min = INF;
		rep(j, 256)Min = min(Min, dp[n][j]);
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 23260
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
struct node
{
    ll x,y;
}s[100010];
bool cmp(node a,node b)
{
    return a.x<b.x;
}
int main()
{
   int n,m;
   scanf("%d%d",&n,&m);
   for(int i=1;i<=n;i++)
   {
       scanf("%lld%lld",&s[i].x,&s[i].y);
   }
   sort(s+1,s+1+n,cmp);
   ll ans=0;
   for(int i=1;i<=n;i++)
   {
       if(m>=s[i].y)
        ans+=s[i].x*s[i].y,m-=s[i].y;
       else
       {
           ans+=s[i].x*m;break;
       }
   }
   printf("%lld\n",ans);
   return 0;

}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(50000)

def findset(x,element,weight):
    if(x != element[x]):
        element[x],s = findset(element[x],element,weight)
        weight[x] += s
    return element[x],weight[x]

def union(x,y,element,weight,w):
    x,wx = findset(x,element,weight)
    y,wy = findset(y,element,weight)
    link(x,y,w+wy-wx,element,weight)

def link(x,y,z,element,weight):

    element[x] = y
    weight[x] = z

n,q = map(int, input().split());

element = [i for i in range(n)]
weight = [0 for i in range(n)]

for i in range(q):
    inp = map(int, input().split());
    inp = list(inp)    
    if(inp[0] == 0):
        x,y,w = inp[1],inp[2],inp[3]
        union(x,y,element,weight,w)
    else:
        x,y = inp[1],inp[2]
        x,wx = findset(x,element,weight)
        y,wy = findset(y,element,weight)
        if(x == y):
            print(wx-wy)
        else:
            print('?')


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

int main(){
    int n;
    ll d;
    cin >> n >>d;
    int ans =0;
    vector<int>x(n), y(n);
    ll d2;
    rep(i,n){
    cin >> x[i]>>y[i];
        d2 = pow(x[i], 2) + pow(y[i], 2);
        if(d2<=d*d)
            ans++;
    }
    cout <<ans<<endl;
}





Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

using iii = tuple<int, int, int>;
int l;

void solve() {
  int n = 0;
  for (int i = 20; i >= 0; i--)
    if (l & (1 << i)) { n = i + 1; break; }
  vector<iii> edges;
  for (int i = 0; i < n - 1; i++) {
    edges.push_back(iii(i + 1, i + 2, 0));
    edges.push_back(iii(i + 1, i + 2, (1 << i)));
  }
  int cur = (1 << (n - 1));
  for (int i = 0; i < n - 1; i++) if (l & (1 << i)) {
    edges.push_back(iii(i + 1, n, cur));
    cur += (1 << i);
  }
  assert(cur == l);

  printf("%d %d\n", n, sz(edges));
  for (int i = 0; i < sz(edges); i++) {
    printf("%d %d %d\n", get<0>(edges[i]), get<1>(edges[i]), get<2>(edges[i]));
  }
}

int main() {
  scanf("%d", &l);
  solve();
}



Measured memory_bytes: 256
def divide_apple(divide_num, num)
  ans = (100**divide_num) * num
  if num == 100 then 
    ans += 100**divide_num
  end
  puts ans
end

input = gets()
arr = input.split(" ")

divide_num = arr[0].to_i
num = arr[1].to_i

divide_apple(divide_num, num)

Measured memory_bytes: 1788
n, Y = map(int, input().split())

for x in range(n+1):
  for y in range(n+1):
    z = n - x - y
    if z >= 0 and 10000*x + 5000*y + 1000*z == Y:
      print("%d %d %d" % (x, y, z))
      exit()
print('-1 -1 -1')

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 ll n;
 cin>>n;
 map<string,int>m;
 for(int i=0;i<n;i++)
 {
     string a;
     cin>>a;
     m[a]++;
 }
 int ma=0;
 for(auto x:m)
 {
     if(x.second>ma)
     {
         ma=x.second;
     }
 }
 //cout<<ma<<"\n";
 for(auto x:m)
 {
     if(x.second==ma)
     {
         cout<<x.first<<endl;
     }
 }
}



Measured memory_bytes: 19184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int[] as = new int[n];
        int even = 0, odd = 0;

        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            if (as[i] % 2 == 0)
                even++;
            else
                odd++;
        }

        long[][] C = new long[n+1][n+1];
        C[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0)
                    C[i][0] = C[i-1][0];
                else
                    C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }

        long ans = 0L;
        if (p == 0) {
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= i; j++) {
                    if (even >= j && odd >= i - j && (i - j) % 2 == 0)
                        ans += C[even][j] * C[odd][i - j];
                }
            }
        }
        else {
            for (int i = 0; i <= n; i++) {
                for (int j = 1; j <= i; j += 2) {
                    if (odd >= j && even >= i - j)
                        ans += C[odd][j] * C[even][i - j];
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import java.io.*;
import java.util.*;

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

    static int[] a = new int[4];
    static boolean[] used =new boolean[4];
    static boolean[][] edge = new boolean[4][4];

    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            int a = in.i() - 1;
            int b = in.i() - 1;
            edge[a][b] = edge[b][a] = true;
        }
        System.out.println(dfs(0, new int[4], new boolean[4]) ? "YES" : "NO");
    }

    static boolean dfs(int k, int[] a, boolean[] used) {
        if (k == 4) {
            int u = a[0];
            for (int i = 1; i < 4; i++) {
                int v = a[i];
                if (!edge[u][v]) return false;
                u = v;
            }
            return true;
        } else {
            for (int i = 0; i < 4; i++) {
                if (!used[i]) {
                    used[i] = true;
                    a[k] = i;
                    if (dfs(k + 1, a, used)) return true;
                    used[i] = false;
                }
            }
        }
        return false;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32756
from collections import defaultdict
d = defaultdict(int)

N = int(input())
li = list(map(int, input().split()))

for i in li:
  d[i] += 1
  
ans = 0  

for i in d:
  if d[i] > i:
    ans += d[i] - i
    
  if d[i] < i:
    ans += d[i]
    
print(ans)

Measured memory_bytes: 18676
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " "
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    if(!m)return 1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    ll N,K;
    cin >> N >> K >> S;
    ll happy = 0;
    rep(i,N - 1){
        if(S[i] == S[i + 1])happy++;
    }
    cout << min(N - 1,happy + K * 2) << endl;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}int n,x,y,xx,yy,zz;
int main(){
	n=read();for (int i=1;i<=n;i++){
		x=read();y=0;while (x%2==0)x/=2,y++;
		if (y>=2)zz++;else if (y==0)xx++;else yy++;
	}if (yy){
		if (xx>zz)puts("No");else puts("Yes");
	}else if (xx>zz+1)puts("No");else puts("Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)

using namespace std;

const int maxn=100005;

struct data {
	int x,id;
	bool operator < (const data &other) const {
		return x<other.x;
	}
}a[maxn<<1];
int r,c,n,idcnt;

int check(int x,int y) {
	if(x==0) return y;
	else if(y==c) return c+x;
	else if(x==r) return 2*c-y+r;
	else if(y==0) return 2*c+2*r-x;
	else return -1;
}

int main() {
	scanf("%d%d%d",&r,&c,&n);
	rep(i,1,n) {
		int x,y,c,d;
		scanf("%d%d",&x,&y);
		c=check(x,y);
		scanf("%d%d",&x,&y);
		d=check(x,y);
		if(~c&&~d) {
			++idcnt;
			a[idcnt*2-1]=(data){c,idcnt};
			a[idcnt*2]=(data){d,idcnt};
		}
	}
	sort(a+1,a+2*idcnt+1);
	static int stk[maxn<<1],top;
	rep(i,1,2*idcnt) {
		if(top&&stk[top]==a[i].id) top--;
		else stk[++top]=a[i].id;
	}
	puts(top?"NO":"YES");
	return 0;
}

Measured memory_bytes: 2176
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int x,y;
    cin >> x >> y;
    //2 legs or 4 legs
    for (int i = 0; i <= x;++i)
    {
        if(i*2+(x-i)*4==y)
        {
            cout << "Yes";
            exit(0);
        }
    }

    cout << "No";

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll big=998244353;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    string s;
    cin >> s;
    int cnt=1;
    bool now=false;
    bool last=false;
    rep2(i,1,s.size()){
        if(now){
            cnt++;
            now=false;
            last=true;
            continue;
        }
        if(s[i-1]!=s[i]||last){
            cnt++;
            last=false;
        }
        else now=true;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3764
N = int(input())


BASE_CHR = 96
# chr(97) # a

result = ""

while True:
    temp = N % 26
    flag = False
    if temp == 0:
        result += "z"
        flag = True
    else:
        result += chr(BASE_CHR+temp)

    N = N // 26

    if flag:
        N -= 1

    if N == 0 :
        break

print(result[::-1])


Measured memory_bytes: 9172
#include <iostream>
#include <set>

using namespace std;

int main() {
    int n;  cin >> n;
    int d;
    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> d;
        s.insert(d);
    }

    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        if (s.find(i) != s.end())
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
long long GCD(long long a,long long b);
signed main(){
    int x,y;
    cin>>x>>y;
    cout<<GCD(x,y)<<'\n';
    return(0);
}
long long GCD(long long a,long long b){
    while(b!=0){
        long long r=a%b;
        a=b;
        b=r;
    }
    return(a);
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
void maxSum(int a[],int n);
int main(){
	int n;
	while(cin>>n,n){
		int sum=0,a[5001],ans=-999999999;
		for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++){
            sum=0;
            for(int j=i;j<n;j++){
                sum+=a[j];
                ans=max(sum,ans);
            }
        }
    cout << ans << endl;
	}
	return 0;
}

void maxSum(int a[],int n){
    int sum = 0;
    int ans = -1;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=i;j<n;j++){
            sum+=a[j];
            ans=max(sum,ans);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9 + 7);

int x;

int main(void) {
	cin >> x;
	int ret = 0;
	if (x == 0)
		ret = 1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3560
N = int(input())
A = list(map(int, input().split(' ')))

sched = abs(A[0])

for i in range(1, N):
    sched += abs(A[i] - A[i - 1])

sched += abs(A[N - 1])

print(sched - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]))

for i in range(1, N - 1):
    print(sched - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]))

print(sched - abs(A[N - 1]) - abs(A[N - 1] - A[N - 2]) + abs(A[N - 2]))

Measured memory_bytes: 14164
#include<bits/stdc++.h>
#define MOD 1000000007
#define fi(i,a,b) for(ll i = a; i < b; i++)
#define fd(i,a,b) for(ll i = a; i >= b; i--)
#define cfi(container,it) for(auto it = container.begin(); it != container.end(); it++)
#define cfd(container,it) for(auto it = container.rbegin(); it != container.rend(); it++)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pbx(num) ll temp; cin>>temp; num.pb(temp) 

using namespace std;
typedef long long ll;

struct modll {
	ll num;
	operator ll() {return num;}
};
modll operator *(modll x, modll y) {return {(x.num * y.num) % MOD} ;}
modll operator +(modll x, modll y) {return {(x.num + y.num + MOD) % MOD} ;}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vi a(n);

	for(int &x : a) {
		cin>>x;
	}

	auto sum = [&](int l, int r) {
		ll s = 0;
		fi(i, l, r + 1)
			s += a[i];

		return s;
	};

	const ll INF = 1e18 + 5;
	// The state dp(i,j) represents the minimum cost of combining the snails from index i to index j
	vector<vll> dp(n, vll(n, INF));

	fd(l, n - 1, 0) {
		fi(r, l, n) {

			if(l == r) {
				dp[l][r] = 0;
				continue;
			}

			// dp[l][r] = INF;
			ll s = sum(l, r);

			fi(i, l, r) {
				dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + s);
			}
		}
	}

	cout<<dp[0][n - 1]<<'\n';
	
	return 0;
}

Measured memory_bytes: 1536
import sys

for line in sys.stdin:
    a, b, c, d, e, f = list(map(float, line.split()))
    x = (c * e - b * f) / (a * e - b * d)
    y = (a * f - c * d) / (a * e - b * d)
    print("{0:.3f} {1:.3f}".format(x + 0., y + 0.))

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

using namespace std;
using ll=long long;

void solve() {
    int n,k;
    cin >> n >> k;
    map<int, vector<int>> mp;
    mp[0].push_back(0);
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        (sum += x) %= k;
        x = (sum-i)%k;
        (x+=k)%=k;
        mp[x].push_back(i);
    }

    ll res = 0;
    for (auto& _: mp) {
        auto& a = _.second;
        sort(a.begin(), a.end());
        int n = a.size();
        for (int i = 0; i < n; i++) {
            int l = a[i];
            int r = lower_bound(a.begin(), a.end(), l+k) - a.begin();
            res += r-i-1;
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
  int a;
  cin>>a;
  if(a<1200) cout<<"ABC"<<endl;
  else if(a>=1200 && a<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, ans;
    while (cin >> n) {
        ans = 0;
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k <= 9; k++) {
                    for (int l = 0; l <= 9; l++) {
                        if (i + j + k + l == n) ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
const int INF=0x7fffffff;
int main(){
	int ans=-INF,n,now=0;
	char a;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a;
		if(a=='I') now++;
		else now--;
		ans=max(ans,now);
	}
	if(ans<=-1) ans=0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256