akhauriyash/Code-Regression huggingface dataset:
a = list(input().upper())
b = list(input().upper())
c = list(input().upper())

turn = 'A'
while True:
    if turn == 'A':
        if not a:
            break
        turn = a.pop(0)
    elif turn == 'B':
        if not b:
            break
        turn = b.pop(0)
    else:
        if not c:
            break
        turn = c.pop(0)

print(turn)

Measured memory_bytes: 3064
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

l = [str(i) for i in range(1,n+1)]
p_list = list(itertools.permutations(l,len(l)))

p_str = [str(i) for i in p]
q_str = [str(i) for i in q]

a = p_list.index(tuple(p_str))
b = p_list.index(tuple(q_str))

print(abs(a-b))

Measured memory_bytes: 8052
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    int ans = n - (k -1) - 1;
    if (k == 1) {
        ans = 0;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const ll MAX_N = 1e3 + 3, MOD = 1e9 + 7;
ll X;
string S, T;

bool prime(ll d) {
    if (d == 1)
        return false;

    for (int i = 2; i * i <= d; i++)
        if (d % i == 0)
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> X;
    while (!prime(X))
        X++;

    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MAX 11
using namespace std;
int main(void){
	while(true){
		int n;
		int Mat[MAX][MAX]={{0,},};
		cin >> n;
		if( n == 0 ) break;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> Mat[i][j];
				Mat[i][n] += Mat[i][j];
				Mat[n][j] += Mat[i][j];
			}
			Mat[n][n] += Mat[i][n];
		}
		for(int i = 0; i < n+1; i++){
			for(int j = 0; j < n+1; j++){
				printf("%5d", Mat[i][j]);
			}
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h,w,n;
	cin >> h >> w >>n;
	vector<pii> a(n);
	rep(i,n){
		int y,x; cin >>y >>x;
		a[i] = pii(y-1,x-1);
	}
	vector<ll> ans(10);
	map<pii, int> mp;
	for(auto z: a){
		int cy , cx; tie(cy, cx) = z;
		rep2(i,-1,2) rep2(j,-1,2){
			if(cy+i<1 || cy+i>h-2 || cx+j<1 || cx+j>w-2) continue;
			//printf("c%d:%d  ",cy+i,cx+j);
			mp[pii(cy+i, cx+j)]++;
		}
	
	}
	ll sm=0;
	for(auto z: mp) ans[z.second]++;
	rep2(i,1,10) sm += ans[i];
	ans[0] = ((ll)h -2) * (w -2) - sm;
	rep(i,10) cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 57344
N,M = map(int,input().split())
road = [[10**6]*N for i in range(N)]
tmp = []
for i in range(M):
    a,b,c = map(int,input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c
    tmp.append([a-1,b-1,c])

for k in range(N):
   for i in range(N):
       for j in range(N):
           road[i][j] = min(road[i][j],road[i][k] + road[k][j]) 
ans = 0
for a,b,c in tmp:
    if road[a][b] != c:
        ans += 1

print(ans)


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N; 
    cin>>N;
    
    vector<bool> erats(10000001, true);
    vl div(10000001, 0);
    REP(i, 1, 10000001){            
        long j = i;
        while(j <= 10000000){
            div[j]++;
            j += i;
        }    
    }
    long ans = 0;
    REP(i, 1, N+1){
        ans += (long)i * div[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 82716
using System;
class Program
 {
        static void  Main(string[] args)
        {
    　　int a,b,c;
        string s;
            a = int.Parse(Console.ReadLine()); //標準入力
            s = Console.ReadLine(); //標準入力
            if (a >= 3200){
              Console.Write(s);
            }
            else{
              Console.Write("red");
            }
        }
 }

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

int main(void) {
    int n;cin>>n;
    int a[n];
    for (int i = 0; i < n; i++) cin>>a[i];
    for (int i = n - 1; i >= 0; i--) {
        cout << a[i];
        if (i > 0) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back 
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n;
	cin>>n;
	ll a[n], count = 0;
	for(ll i=0;i<n;i++){
	    cin>>a[i];
	    if(a[i]!=i+1) count++;
	}
	if(count == 2 || count == 0) cout<<"YES";
	else cout<<"NO";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

	if (k % 2 == 1) {
		ll l = n / k;
		cout << l * l * l << endl;
	}
	else {
		ll l = n / k;
		ll ans = l * l * l;
		l = n / (k / 2) - l;
		ans += l * l * l;
		cout << ans << endl;
	}

}

Measured memory_bytes: 256
##main#######################################

## INPUT ####################################
N=input()
A = list(map(int,list(input().split())))

## PROCESSING ###############################
max=0
ans=0
for n in A:
	if max<n : max=n
	
	if max>n : ans=ans + max-n

## OUTPUT ###################################
#print("++++OUTPUT++++")
#print(A)
print(ans)

Measured memory_bytes: 32536
s = input()
a = int(s[:2]); b = int(s[2:])

def check_mm(n):
    if  0 < n and n < 13:
        return True
    else:
        return False

if check_mm(a) and check_mm(b):
    print('AMBIGUOUS')
elif check_mm(b):
    print('YYMM')
elif check_mm(a):
    print('MMYY')
else:
    print('NA')

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int x,a,b;
  cin >> x >> a >> b;
  abs(x-a)<abs(x-b)?print("A"):print("B");
  return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = nextIntArray();
		int count = 0;
		int max = 0;
		for(int i = 0; i < N - 1; i++){
			if(list.get(i) >= list.get(i + 1)){
				count++;
			}else{
				max = Math.max(max, count);
				count = 0;
			}
		}
		max = Math.max(max, count);
		myout(max);
	}
	//Method addition frame start




	//Method addition frame end
}


Measured memory_bytes: 50188
x, k, d = map(int, input().split())

x = abs(x)

if x - k * d > 0:
    ans = x - k * d
else:
    if (k - x // d) % 2 == 0:
        ans = x - d * (x // d)
    else:
        ans = abs(x - d * (x // d) - d)

print(ans) 


Measured memory_bytes: 9052
#include <stdio.h>

int n,P[8][8],row[8],col[8],dpos[16],dneg[16],t,y;

void qprint(void)
{
  int i,j;
  for(i=0;i<8;i++)
    {
      for(j=0;j<8;j++)
        {
          if(P[i][j]==1)
            printf("Q");
          else
            printf(".");
        }
      printf("\n");
    }
}
void search(int i)
{
  int j;

  if(i==8)
    {
      qprint();
      return;
    }

  if(row[i]==1)
    {
      search(i+1);
    }

  for(j=0;j<8;j++)
    {

      if(col[j]==1||dpos[i+j]==1||dneg[i-j+7]==1)continue;

      col[j]=1;
      dpos[i+j]=1;
      dneg[i-j+7]=1;
      P[i][j]=1;

      search(i+1);

      P[i][j]=0;
      col[j]=0;
      dpos[i+j]=0;
      dneg[i-j+7]=0;
    }
}

int main()
{
  int i,j;

  for(i=0;i<8;i++)
    {
      for(j=0;j<8;j++)
        {
          P[i][j]=0;
          dpos[i+j]=0;
          dneg[i+j]=0;
        }
      row[i]=0;
      col[i]=0;
    }




  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d %d",&t,&y);
      row[t]=1;
      col[y]=1;
      dpos[t+y]=1;
      dneg[t-y+7]=1;
      P[t][y]=1;
    }

  search(0);

  return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5;
int main(){
  int x,y;
  cin>>x>>y;
  for (int i=0; i<=x; i++){
    if (2*i + 4*(x-i) == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.*;


public class Main {
    public static void main(String args[]){
            Scanner sc = new Scanner(System.in);
           
            long a = sc.nextLong();
            long n = sc.nextLong();
            long[] yakusu = new long[2000000];
            long pro = 1;
            if (a == 1) {
                System.out.println(n);
            } else {
                for (int i = 2; i <= Math.sqrt(n); i++) {
                    while (n >= i && n % i == 0) {
                        yakusu[i] = yakusu[i] + 1;
                         n = n / i;
                    }
                }   
                for (int i = 2; i < yakusu.length; i++) {
                    while (yakusu[i] >= a) {
                        pro = pro * i;
                        yakusu[i] = yakusu[i] -a;
                    }
                }
                System.out.println(pro);
            }


            sc.close();
        }
    
}



Measured memory_bytes: 40148
n = int(input())
A = [int(input()) for _ in range(n)]
ans = 0
temp = 0
for i in range(n):
    ans += (A[i]+temp)//2
    if A[i] != 0:
        temp = (A[i]+temp)%2
    else:
        temp = 0
print(ans)

Measured memory_bytes: 49752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
int A[1000], B[1000];
int cntr[1000], cntc[1000]; // cntr[i]:i行目の確定要素数, cntc[i];i列目の確定要素数
int g[1123456][2];

int main() {
	cin >> N >> M;
	REP(i, N) scanf("%d", A + i);
	REP(i, M) scanf("%d", B + i);
	
	fill(g[0], g[N * M + 1], INF);
	REP(i, N) g[A[i]][0] = i;
	REP(i, M) g[B[i]][1] = i;
	
	ll ans = 1;
	ll cnt = 0, rowc = 0, colc = 0; // 合計確定要素数, 出現した行の種類数, 列..
	
	for (int i = N * M; i >= 1; i--) {
		if (g[i][0] != INF && g[i][1] != INF) {
			
		}
		else if (g[i][0] != INF) {
			(ans *= colc - cntr[g[i][0]]) %= MOD;
		}
		else if (g[i][1] != INF) {
			(ans *= rowc - cntc[g[i][1]]) %= MOD;
		}
		else {
			(ans *= colc * rowc - cnt) %= MOD;
		}
		
		if (g[i][0] != INF) {
			rowc++;
			cntr[g[i][0]]++;
		}
		if (g[i][1] != INF) {
			colc++;
			cntc[g[i][1]]++;
		}
		
		cnt++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8448
import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int l = str.length();
		char ch[] = str.toCharArray();
		for(int i=0;i<l;i++){
			if(Character.isUpperCase(ch[i])){
				ch[i] = Character.toLowerCase(ch[i]);
			}
			else if(Character.isLowerCase(ch[i])){
				ch[i] = Character.toUpperCase(ch[i]);				
			}
		}
		System.out.println(ch);		
	}
}	

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    for1(k, 360) {
        if (k * n % 360 == 0) {
            cout << k << '\n';
            break;
        }
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N, M,ans;
	ans = 0;
	cin >> N >> M;
	vint X(M),dif(M-1),ma(N-1);
	if (N < M) {
		for (int i = 0; i < M; i++) cin >> X[i];
		sort(X.begin(), X.end());

		for (int i = 1; i < M; i++) {
			dif[i - 1] = X[i] - X[i - 1];

		}
		sort(dif.rbegin(), dif.rend());




		for (int i = 0; i < N - 1; i++) {
			ma[i] = dif[i];
		}

		for (int i = 0; i < M - 1; i++) {
			ans += dif[i];
		}

		for (int i = 0; i < N - 1; i++) {
			ans -= ma[i];
		}
	}
	
	cout << ans << endl;
}



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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    int a, b;
    cin >> a >> b;

    // 処理
    // 出力
    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int power(int x, int n) {
	int res = 1LL;
	while (n > 0) {
		if (n & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return res % MOD;
}

signed main() {
  INIT;
  VAR(string,l);
  int n = l.size();

  int ans=0, cnt=0;
  REP(i,n){
    if (l[i]=='0') continue;
    (ans += power(2,cnt) * power(3,n-(i+1))) %= MOD;
    ++cnt;
  }
  (ans += power(2,cnt)) %= MOD;
  OUT(ans)BR;
  
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string t = "ATCG";
  int ans = 0;
  int cnt = 0;
  rep(i, s.size()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
int a[200000+50],b[200000+50],c[200000+50],d[200000+50];
int main()
{
	int n,m,i;
	while(scanf("%d",&n)!=EOF)
	{
		scanf("%d",&m);
		for(i=0;i<m;i++)
		{
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]==1)
			c[b[i]]++;
			if(b[i]==1)
			c[a[i]]++;
			if(a[i]==n)
			d[b[i]]++;
			if(b[i]==n)
			d[a[i]]++;
		}
			for(i=0;i<n;i++)
				if(c[i]!=0&&d[i]!=0)
				{
					printf("POSSIBLE\n");
					break;
				}
				if(i==n)
					printf("IMPOSSIBLE\n");
			for(i=0;i<m;i++)
			{
				a[i]=0;b[i]=0;
			}
			for(i=0;i<n;i++)
			{
				c[i]=0;d[i]=0;
			}
	}
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;

        a.pback(tmp);
    }

    ll ans = 1;

    vector<int> count(3);

    //count[0] = 1;

    for(int i = 0; i <= n - 1; i++){

        ll samecount = 0;

        rep(j,3){
            if(a[i] == count[j]){
                samecount++;
            }
        }

        ans = (ans * samecount) % MODN;

        rep(j,3){
            if(a[i] == count[j]){
                count[j]++;
                break;
            }
        }

        cerr << count[0] << " " << count[1] << " " << count[2] << endl;

        cerr << ans << endl;
    }

    cerr << count[0] << " " << count[1] << " " << count[2] << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int a[3];
    for(int i=0;i<3;i++)
    scanf("%d",a+i);
    int num5=0,num7=0;
    for(int i=0;i<3;i++)
    {
        if(a[i]==5)num5++;
        if(a[i]==7)num7++;
    }
    if(num5==2&&num7==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = sc.nextInt();
            ans += (h[i]>=k)?1:0;
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 49792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[10000];
int main() { 
  int n,k,A,ans;
  char c;
  string s;
  cin >>n>>k;
  if(n>0&&10>n&&k>0&&10>k)cout<<n*k<<endl;
  else cout<<-1<<endl;
  vector<int> a(n),val(n);
  
  //cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define LL long long
#define rg register

using namespace std;

inline LL read() {
    LL x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

LL n, m, ans1, ans2;

int main() {
    n = read(); m = sqrt(n);
    if(n == 1) {cout << 1 << endl; return 0;}
    if(n == 2) {cout << 1 << endl; return 0;}
    for(rg LL i = 2; i <= m; ++i) {
        LL now = n;
        if(!(now % i)) {
            while(!(now % i)) now /= i;
            if(!((now - 1) % i)) ++ans1;
        }
        else if(!((now - 1) % i)) {
            if(i * i == now - 1) ++ans2;
            else ans2 += 2;
        }
    }
    printf("%lld\n", ans1 + ans2 + 2);
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input().rstrip('\n')

K -= 1

if K == 0:
    print(S[0].lower() + S[1:])
elif K == N - 1:
    print(S[0:K] + S[K].lower())
else:
    print(S[0:K] + S[K].lower() + S[K + 1:N])


Measured memory_bytes: 3060
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n,k;
vll a;
lli ans = 1ll << 62;
int main(){
    cin >> n >> k;
    a = vll(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    lli bit_n = 1 << n;
    for(lli i = 0;i < bit_n;i++){
        lli k_ = 0;
        for(lli j = 0;j < n;j++){
            if(i & 1 << j) k_++;
        }
        if(k != k_) continue;
        lli max_h = 0;
        lli ans_ = 0;
        for(lli j = 0;j < n;j++){
            if(i & 1 << j){
                if(a[j] <= max_h) ans_ += max_h + 1 - a[j],max_h++;
            }
            max_h = max(max_h,a[j]);
        }
        ans = min(ans,ans_);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
N, M = map(int, input().split())
uf = UnionFind(N)
import sys
input = sys.stdin.readline
import collections
for i in range(M):
  A, B = map(int, input().rstrip().split())
  uf.union(A-1, B-1)
doku = uf.parents.count(-1)
all = uf.group_count() - doku
ans = all + doku -1
print(ans)

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

int main() {
  long n, k;
  double ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long j = i + 1;
    double ians = 1.0;
    while (j < k) {
      j *= 2;
      ians /= 2.0;
    }
    ans += ians;
  }
  cout << fixed << setprecision(10);
  cout << ans / (double)n;
}

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

int main() {
    int N, M;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    cin >> M;
    vector<int> q(M);
    for (int i = 0; i < M; ++i) cin >> q[i];
    
    // binary search
    int res = 0;
    
    for (int i = 0; i < M; ++i) {
        if (*lower_bound(vec.begin(), vec.end(), q[i]) == q[i]) res++;
    }
    
    cout << res << "\n";
    
    return 0;
}



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

int main(){
    int width,height,x,y,radius;
    cin >> width >> height >> x >> y >> radius;
    cout << (x + radius > width ||
            y + radius > height ||
            x - radius < 0      ||
            y - radius < 0      ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		String ans=(a<=8&&b<=8)?"Yay!":":(";
		System.out.println(ans);

	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){
    int X,N;
    cin >> X >> N ;
    int p[N];
    int ans=X;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    for(int i=0;i<51;i++){
        if(X-i ==0){
            ans=0;
            break;
        }else{ 
            bool flag=true;
            for(int j=0;j<N;j++){
                if(X-i==p[j]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                ans=X-i;
                break;
            }
            flag=true;
            for(int j=0;j<N;j++){
                if(X+i==p[j]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                ans=X+i;
                break;
            }
            if(X+i==101){
                ans=101;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;

}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if( abs( a-c ) <= d or (abs(a-b) <= d and abs(b-c)<=d))
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    int q, m;
    cin >> q >> m;

    int min_ = INT_MAX;

    for(int i=0, val; i<q; i++) {
        cin >> val;
        m -= val;
        min_ = min(min_, val);
    }

    cout << q + m/min_ << '\n';

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
string a;
string b;
bool judge = false;


signed main(void) {
    cin >> a >> b;

    int l = a.length();
    rep(i,l){
        rep(j,l){
            int k;
            if(i+j < l){
                if(a[i+j] != b[j]){
                    break;
                }
            }else{
                if(a[i+j-l] != b[j]){
                    break;
                }
            }
            if(j==l-1){
                judge = true;
            }
        }
    }

    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        ans+=i;
    }
    cout<<ans;
    return 0;
}
//make all values ll


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

int main() {
	
	string s;
	cin >> s;
	sort(all(s));
	if(s == "abc") puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#
#フェネックとすぬけさんが最短でお互いのマスへ向かう時の、ぶつかる点を求めて
#木を分割する。分割した二つのマスを数えて比較し、大きい方が勝利

import sys
sys.setrecursionlimit(1000000)

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

#二人がぶつかる点を求める（木を分割する点を求める）
col = [ -1 for i in range(N)]
col[0] = 0
p = []
path = [ 0 for i in range(10**5+1)]
def dfs(n,c):
    global p
    if n == N - 1:
        p = path
    path[c] = n
    for v in e[n]:
        if col[v] == -1:
            col[v] = c + 1
            dfs(v,c+1)
            if p:
                return
dfs(0,0)

t = col[N-1] + 1
if t % 2 ==0:
    sn = p[t//2]
else:
    sn = p[t//2+1]


#フェネック側の木のマス数を数える
colfn = [ -1 for i in range(N)]
colfn[0] = 0
def dfs2(n,c):

    for v in e[n]:
        if v == sn:
            continue
        elif colfn[v] == -1:
            colfn[v] = c + 1
            dfs2(v,c+1)

dfs2(0,0)

fennec = -1
for i in range(N):
    if colfn[i] != -1:
        fennec += 1


#すぬけさん側は全マス数からフェネックのマスを引けば良い
snuke = N - fennec - 2

if fennec > snuke:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 118420
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    long double a,b,h,m;cin >> a >> b >> h >> m;
    long double aa = 30 * h + m / 2.;
    long double bb = m * 6;
    long double t = aa - bb;
    long double tp = t / 180. * acosl(-1);
    cout << setprecision(30) << fixed << sqrtl(a * a + b * b - 2 * a * b * cosl(tp)) << endl;
    return 0;
}



Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
template<typename T = int, T mod = 1'000'000'007, typename U = long long>
struct umod{
        T val;
        umod(): val(0){}
        umod(U x){ x %= mod; if(x < 0) x += mod; val = x;}
        umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
	umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
	umod& operator *= (umod oth){ val = ((U)val) * oth.val % mod; return *this; }
	umod& operator /= (umod oth){ return *this *= oth.inverse(); }
        umod& operator ^= (U oth){ return *this = pwr(*this, oth); }
	umod operator + (umod oth) const { return umod(*this) += oth; }
	umod operator - (umod oth) const { return umod(*this) -= oth; }
	umod operator * (umod oth) const { return umod(*this) *= oth; }
	umod operator / (umod oth) const { return umod(*this) /= oth; }
        umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
	bool operator < (umod oth) const { return val < oth.val; }
	bool operator > (umod oth) const { return val > oth.val; }
	bool operator <= (umod oth) const { return val <= oth.val; }
	bool operator >= (umod oth) const { return val >= oth.val; }
	bool operator == (umod oth) const { return val == oth.val; }
	bool operator != (umod oth) const { return val != oth.val; }
        umod pwr(umod a, U b) const { umod r = 1; for(; b; a *= a, b >>= 1) if(b&1) r *= a; return r; }
        umod inverse() const {
		U a = val, b = mod, u = 1, v = 0;
		while(b){
			U t = a/b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		if(u < 0)
			u += mod;
		return u;
        }
};

template<typename U>
struct NCR {
        vector<U> fact, ifact;
        NCR(int size){
                fact.resize(size + 1); ifact.resize(size + 1);
                fact[0] = 1;
                for(int i = 1; i <= size; i++) fact[i] = fact[i - 1] * i;
                ifact[size] = fact[size].inverse();
                for(int i = size - 1; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1);
        }
        U ncr(int n, int r){
                if(n < r) return 0;
                return fact[n] * ifact[r] * ifact[n - r];
        }
};
using U = umod<>;
using N = NCR<U>;
int main(){
	int h, w, k; cin >> h >> w >> k;
	U ans = 0;
	const int sz = 20'000'005;
	N kit(sz);
	/* i != 0 & j != 0 */ {
		U indep = kit.ncr(k, 2) / kit.ncr(h + w, 2);
		U dep = kit.ncr(k, 3) / kit.ncr(h + w, 3);
		dep /= 3;
		dep *= (h + w - 2);
		ans += U(h) * U(w) * (dep + indep); 	
	}
	/* i == 0 & j != 0 */ {
		U indep = kit.ncr(k, 1) / kit.ncr(h + w, 1);
		U dep = kit.ncr(k, 2) / kit.ncr(h + w, 2);
		dep /= 2;
		dep *= (h + w - 1);
		ans += U(h) * (dep + indep); 	
	}
	/* i != 0 & j == 0 */ {
		U indep = kit.ncr(k, 1) / kit.ncr(h + w, 1);
		U dep = kit.ncr(k, 2) / kit.ncr(h + w, 2);
		dep /= 2;
		dep *= (h + w - 1);
		ans += U(w) * (dep + indep); 	
	}
	/* i == 0 & j == 0 */ {
		ans += k;
	}
	for(int i = (h + w); i >= (h + w - k + 1); i--) ans *= i;
	cout << ans.val << endl;
	return 0;
}


Measured memory_bytes: 156544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int t = sc.NextInt();
        int a = sc.NextInt();
        int[] h = sc.IntArray();

        int answer = 0;
        decimal min = int.MaxValue;

        for (int i = 0; i < n; i++)
        {
            decimal tmp = (decimal)t - (decimal)0.006 * (decimal)h[i];
            decimal diff = Math.Abs((decimal)a - tmp);
            if (diff < min)
            {
                min = diff;
                answer = i + 1;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13340
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    vector<ll>dec(200100);
    vector<ll>sum(s.length()+1);
    vector<ll>index(2020);
    dec[0]=1;
    FOR(i,1,200100){
        dec[i]=(dec[i-1]*10)%2019;
    }
    reverse(ALL(s));

    REP(i,s.length()){
        dec[i] = (dec[i]*(s[i]-'0'))%2019;
    }
    sum[0]=0;
    FOR(i,1,s.length()+1){
        sum[i]=(sum[i-1]+dec[i-1])%2019;
    }

    REP(i,2020)index[i]=0;

    REP(i,sum.size()){
        index[sum[i]]++;
    }
    ll answer = 0;
    REP(i,index.size()){
        answer+=(index[i]*(index[i]-1)/2);
    }
    
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 6812
// B.cpp

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int A,
		B,
		M,
		answer,
		m1,
		m2,
		m3,
		ab_min = 1000000;
	cin >> A >> B >> M;
	vector<int>a(A);
	vector<int>b(B);
	for (auto& i : a) {
		cin >> i;
		ab_min = min(ab_min, i);
	}
	answer = ab_min;
	ab_min = 1000000;
	for (auto& i : b) {
		cin >> i;
		ab_min = min(ab_min, i);
	}
	answer += ab_min;
	for (int i = 0; i < M; i++) {
		cin >> m1 >> m2 >> m3;
		answer = min(answer, a[m1 - 1] + b[m2 - 1] - m3);
	}
	cout << answer << endl;
}

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

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> A(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A.at(i).at(j)=='#'){
        continue;
      }
      int count=0;
      for(int d=0;d<8;d++){
        int NX=dx[d]+i;
        int NY=dy[d]+j;
        if(0<=NX && NX<H && 0<=NY && NY<W && A.at(NX).at(NY)=='#'){
          count++;
        }
      }
      char D='0'+count;
      A.at(i).at(j)=D;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << A.at(i).at(j);
      if(j==W-1){
        cout << endl;
      }
    }
  }
}
  
          
      
  
  

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
  char str1[]="ABC";
  char str2[]="ARC";
  char strn[3];

  scanf("%s\n",strn);

  if(strcmp(str1,strn)==0){
    printf("%s\n", str2);
  }

  if(strcmp(str2,strn)==0){
    printf("%s\n", str1);
  }
  return 0;
}


Measured memory_bytes: 2060
n=int(input())
arr=list(map(int,input().split()))
if n%2==1:
  cnt=[0]*(n//2+1)
  for i in range(n):
    cnt[arr[i]//2]+=1
  if cnt[0]==1 and cnt.count(2)==n//2:
    print((2**(n//2))%(10**9+7))
  else:
    print(0)
else:
  cnt=[0]*(n//2)
  for i in range(n):
    cnt[(arr[i]-1)//2]+=1
  if cnt.count(2)==n//2:
    print((2**(n//2))%(10**9+7))
  else:
    print(0)

Measured memory_bytes: 14008
N = int(input())
dp = [[0] * 3 for i in range(N + 1)]

for i in range(N):
  act = list(map(int,input().split()))
  for j in range(3):
    for a in range(len(act)):
      if a == j:
        continue
      if dp[i + 1][a] < dp[i][j] + act[a]:
        dp[i + 1][a] = dp[i][j] + act[a]

print(max(dp[-1]))


Measured memory_bytes: 28824
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<pair<pair<int,int>, pair<int,int>>> ans;
int main(){
    cout << fixed << setprecision(10);
    int h,w;
    cin >> h >> w;
    vector<vector<int>> v(h,vector<int>(w));
    rep(i,h) rep(j,w) cin >> v[i][j];
    int i = 0, j = 0;
    int itr = 0;
    while(itr < h*w){
        //cout << i << " " << j <<" " << itr <<  endl;
        if(v[i][j] & 1){
            int ni = i, nj = j;
            if(ni % 2 == 0){
                if(nj < w-1) nj++;
                else ni++;
            }else{
                if(nj > 0) nj--;
                else ni++; 
            }
            if( ni < h && nj < w){
                ans.push_back(make_pair(make_pair(i+1,j+1),make_pair(ni+1,nj+1)));
                v[ni][nj] ++;
            }
            i = ni, j = nj;
            itr++;
        }else{
            int ni = i, nj = j;
            if(ni % 2 == 0){
                if(nj < w-1) nj++;
                else ni++;
            }else{
                if(nj > 0) nj--;
                else ni++;  
            }
            i = ni, j = nj;
            itr++;           
        }
    }
    cout << ans.size() << endl;
    for(auto u : ans){
        cout << u.first.first << " " << u.first.second << " " << u.second.first << " " << u.second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 6344
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

int main() {fio;
	string f;
	cin >> f;
	for(auto &c : f) if(c == '?') c = 'D';
		cout << f;
    return 0;
}

Measured memory_bytes: 3740
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(al, start):
	mc = 0
	is_m = start
	pre_total_sum=0
	for v in al:
		pre_total_sum += v
		if is_m*pre_total_sum <= 0:
			mc += abs(pre_total_sum-is_m)
			pre_total_sum = is_m
		is_m *= -1
	#pa(mc)
	return mc

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	ret = min(cc(al, -1), cc(al, 1))
	return ret
	
	
	
#+++++
isTest=False

def pa(*vl):
	if not isTest:
		return
	for v in vl:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
    string S;
    cin >> S;
    if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256