akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();

            if(op.equals("?")) break;

            int ans = 0;
            switch (op){
                case "+":
                    ans = a+b;
                    break;
                case "-":
                     ans = a-b;
                     break;
                case "*":
                    ans = a*b;
                    break;
                case "/":
                    ans = a/b;
                    break;
            }
            System.out.printf("%d\n", ans);
        }
    }
}



Measured memory_bytes: 26392
#include <iostream>
#define N 10
using namespace std;
int main(void){
  int a,b,c,d,n;
  while(cin >> n){
    int cnt=0;
    for(a=0;a<N;a++){
      for(b=0;b<N;b++){
	for(c=0;c<N;c++){
	  for(d=0;d<N;d++){
	    if(a+b+c+d==n)cnt++;
	  }
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  llint x,y;
  cin>>x>>y;
  //caricurate
  int i=0;
  while(x<=y){
  x*=2;i++;
  }
  //output

cout<<i<<endl;
}

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

const int MAXN = 212345;

int a[MAXN], v[MAXN];
vector <int> ans;

int main () {

	int n;
	cin >> n;

	for (int i = 1; i <= n; ++i) scanf ("%d", a + i);

	for (int i = n; i > 0; --i) {
		int put = a[i];
		for (int j = i + i; j <= n; j += i) {
			put ^= v[j];
		}

		v[i] = put;
		if (put) ans.push_back (i);
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); ++i)
		printf ("%d%c", ans[i], " \n"[i == ans.size() - 1]);

	return 0;
}

Measured memory_bytes: 3064
import java.util.*;

class Main {
  public static final long MOD = 1000000007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    char[] charS = S.toCharArray();
    Integer east[] = new Integer[N];
    Integer west[] = new Integer[N];
    int count = 0;
    for(int i=0; i<N; i++){
      if(charS[i] == 'W') count++;
      west[i] = count;
    }
    count = 0;
    for(int i=N-1; i>=0; i--){
      if(charS[i] == 'E') count++;
      east[i] = count;
    }
    int ans;
    ans = west[N-2];
    ans = Math.min(ans, east[1]);
    for(int i=1; i<N-1; i++){
      ans = Math.min(ans, west[i-1]+east[i+1]);
    }
    System.out.println(ans);
    
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 53068
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		HashSet<String> ids = new HashSet<String>();
		for (int i=0; i<n; i++) {
			ids.add(in.next());
		}

		int m = in.nextInt();
		boolean f = true;
		for (int i=0; i<m; i++) {
			String u = in.next();
			if (ids.contains(u)) {
				if (f) {
					out.println("Opened by "+u);
					f = !f;
				} else {
					out.println("Closed by "+u);
					f = !f;
				}
			} else {
				out.println("Unknown "+u);
			}
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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


int main()
{
  int n;
  char c[10];
  while(1)
  {
    cin >> n;
    if(!n)
      break;
    for(int i = 0; i < 10; i++)
      c[i] = 50;

    int cnt = 0;
    while(n > 0)
    {
      c[cnt++] = n % 8;
      n /=  8;
    }

    for(int i = 9; i >= 0; i--)
    {
      //cout << i << ":" << (int)c[i] << endl;                                  
      if(c[i] == 50)
        continue;
      if(c[i] >= 5)
        cout << (char)(c[i] + 2 + '0');
      else if(c[i] >= 4)
        cout << (char)(c[i] + 1 + '0');
      else
        cout << (char)(c[i] + '0');
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007  

int main(){
    ll N;
    ll ans = 0;
    cin >> N;
    for(int i = 1; i < N; i++){
        ans += i * (N - i + 1);
        ll u, v;
        cin >> u >> v;
        ll m = min(u, v);
        ll M = max(u, v);
        ans -= m * (N - M + 1);
    }
    ans += N;
    cout << ans << endl;
}


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

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 高さが全部 0 になるまでやる
    int res = 0;
    while (true) {
        // 最高高さが 0 だったらおしまい
        if (*max_element(h.begin(), h.end()) == 0) break;
        
        // 区間分割する
        int i = 0;
        while (i < N) {
            if (h[i] == 0) ++i; // 0 なら何もせずに次に進む
            else {
                ++res; // 区間の始まり
                while (i < N && h[i] > 0) {
                    --h[i]; // ついでに引いとく
                    ++i; // 区間の終わりまで一気に
                }
            }
        }
    }
    cout << res << endl;
}


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

void solve(){  
	long long a,b,n; 
	cin >> a >> b >> n;
	if(n<b)
	   cout<<(a*n/b);
	else
	   cout<<(a*(b-1)/b);
}
int main(){
	ios_base::sync_with_stdio(0); 
    cin.tie(0);
    cout.tie(0);
    solve();
  return 0;
}


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

int main(){
	char s[100050];
	char temp[10];
	scanf("%s",s);
	int i=0, end=strlen(s);
	int isPosible = 1;
	
	while(isPosible){
		
		if(i==end){
			break;
		}
		strncpy(temp,s+i,5);
		i+=5;
		if(strcmp(temp,"dream")!=0 && strcmp(temp,"erase")!=0){
			isPosible=0;
			//puts("No match");
		}else if(strcmp(temp,"erase")==0){//頭5文字が eraseの場合　次の文字が rならばそれも取り除く
			//puts("erase");
			if(s[i]=='r'){
				//puts("eraser");
				i++;
			}
		}else{//頭5文字が dreamの場合
			//puts("dream");
			if(s[i]=='e' && s[i+1] == 'r'){
				//puts("dreamer?");
				
				strncpy(temp,s+i,5);//dreamerase?
				if(strcmp(temp,"erase")!=0){
					i+=2;
					//puts("dreamer");
				}
			}
		}
	}
	
	if(isPosible){
		puts("YES");
	}else{
		puts("NO");
	}

	return 0;
}

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

int main()
{
    int N,K;
    int h[100000];
    int count=0;
    cin>>N>>K;
    for(int i=0;i<N;i++)cin>>h[i];

    for(int i=0;i<N;i++){
        if(h[i]>=K)count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    int H = 0;
    int W = 0;

    int h = 0;
    int w = 0;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final String[] HW = br.readLine().split("\\s");
      H = Integer.parseInt(HW[0]);
      W = Integer.parseInt(HW[1]);

      final String[] hw = br.readLine().split("\\s");
      h = Integer.parseInt(hw[0]);
      w = Integer.parseInt(hw[1]);

    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    System.out.print((H * W + h * w) - (h * W + H * w));
  }
}




Measured memory_bytes: 22740
N = int(input())
Aprev = list(map(int, input().split()))
A = []
B = []
for i in range(N):
    if i % 2 == 0:
        A.append(Aprev[i])
        B.append(-Aprev[i])
    else:
        A.append(-Aprev[i])
        B.append(Aprev[i])

listaltA = [0]
listaltB = [0]
for i in range(N):
    listaltA.append(listaltA[i] + A[i])
    listaltB.append(listaltB[i] + B[i])
listaltA.pop(0)
listaltB.pop(0)

ans = []
for i in range(N):
    if i == 0:
        ans.append(listaltA[-1])
    else:
        if i % 2 != 0:
            res = listaltA[i - 1] + (listaltB[-1] - listaltB[i - 1])
            ans.append(res)
        else:
            res = listaltB[i - 1] + (listaltA[-1] - listaltA[i - 1])
            ans.append(res)
print(*ans)

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  
  sort(a.rbegin(), a.rend());
  
  int r = a[0];
  for(int i = 1; i < n; i++){
    if(abs(a[0] - 2 * a[i]) <= abs(a[0] - 2 * r)){
      r = a[i];
    }
  }
  
  cout << a[0] << ' ' << r << endl;
  
  return 0;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	//入力
	long N,ans,l,r;
	cin >> N;
	for (long j = 0; j < N; j++) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	//処理
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5;
ll N;
map<ll,ll> mp;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N){
		ll a;
		cin>>a;
		mp[a]++;
	}
	bool ans;
	if(N%3==0){
		vector<ll> xyz;
		ans=true;
		for(auto p:mp){
			if(p.second%(N/3)==0){
				REP(i,p.second/(N/3))xyz.push_back(p.first);
			}else{
				ans=false;
			}
		}
		if(ans){
			ll sm=0;
			REP(i,3)sm^=xyz[i];
			if(sm>0)ans=false;
		}
	}else{
		auto ite=mp.begin();
		if(ite->second==N&&ite->first==0){
			ans=true;
		}else{
			ans=false;
		}
	}
	cout<<(ans?"Yes":"No")<<endl;
}

Measured memory_bytes: 5120
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 305
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int N, M;
	scanf("%d %d", &N, &M);
	vector <vector <int> > k(N + 1, vector <int>());
	for (int i = 1; i <= M; i++) {
		int kk;
		scanf("%d", &kk);
		while (kk--) {
			int kkk;
			scanf("%d", &kkk);
			k[kkk].push_back(i);
		}
	}
	vector <int> p(M + 1);
	for (int j = 1; j <= M; j++) scanf("%d", &p[j]);
	int res = 0;
	for (int st = 0; st < (1 << N); st++) {
		int stt = st;
		vector <int> counts(M + 1, 0);
		for (int pos = 1, stt = st; stt > 0; pos++, stt >>= 1) {
			if (stt & 1) {
				for (int b : k[pos]) counts[b]++;
			}
		}
		bool ok = true;
		for (int j = 1; j <= M; j++) if ((counts[j] & 1) != p[j]) ok = false;
		if (ok) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextInt(scanner)
	b := getNextInt(scanner)

	fmt.Fprintln(writer, int64(a/gcd(a, b))*int64(b))
	writer.Flush()
}
func gcd(m, n int) int {
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    ll ret = 1;
    FOR(i, 1, n) {
        if(s[i] != s[i-1]) ret++;
    }
    cout << ret << endl;

    return 0;
}

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

int day(int m, int d){
	if(m==1)return d;
	if(m==2)return 31+d;
	if(m==3)return 60+d;
	if(m==4)return 91+d;
	if(m==5)return 121+d;
	if(m==6)return 152+d;
	if(m==7)return 182+d;
	if(m==8)return 213+d;
	if(m==9)return 244+d;
	if(m==10)return 274+d;
	if(m==11)return 305+d;
	if(m==12)return 335+d;
}

int main(){
	while(1){
		int m,d;
		std::cin>>m>>d;
		if(m==0)return 0;
		std::string s;
		if(day(m,d)%7==1)s="Thursday";
		if(day(m,d)%7==2)s="Friday";
		if(day(m,d)%7==3)s="Saturday";
		if(day(m,d)%7==4)s="Sunday";
		if(day(m,d)%7==5)s="Monday";
		if(day(m,d)%7==6)s="Tuesday";
		if(day(m,d)%7==0)s="Wednesday";
		std::cout<<s<<std::endl;
	}
}

Measured memory_bytes: 1192
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll maxn=2e3+10;
const ll mod=1e9+7;
const ll maxn2=4e6+20;

#pragma GCC Optimize("Ofast")

ll dp[maxn][maxn];
ll cnk[maxn2],fac[maxn2],inv[maxn2],ifac[maxn2];
ll N,K;
	
ll pw(ll a, ll b) { return b != 0? pw(a * a % mod, b >> 1) * (b & 1? a: 1) % mod: 1; }

void prep(){
	fac[0]=ifac[0]=inv[1]=1;
	FOR(i,1,maxn2-1)
		fac[i]=(i*fac[i - 1])%mod;
	FOR(i,2,maxn2-1) 
		inv[i] = mod - 1LL * (mod / i) * inv[mod % i] % mod;
	FOR(i,1,maxn2-1)
		ifac[i] =(inv[i]*ifac[i-1])%mod;
	FOR(i,(K-2),maxn2-1)
		cnk[i]=(((fac[i]*ifac[K-2])%mod)*ifac[i-K+2])%mod;
}

int main(){
	cin>>N>>K;
	if(K==1){
		cout<<1;
		return 0;
	}
	prep();
	
	dp[1][0]=dp[1][1]=1;
	FOR(i,2,N){
		FORD(j,i,1){
			dp[i][j]=(i*((cnk[(i*K)-j-1]*dp[i-1][j-1])%mod))%mod;
			dp[i][j]=(dp[i][j]+dp[i][j+1])%mod;
		}
		dp[i][0]=dp[i][1];
	}
	cout<<dp[N][0];
}

Measured memory_bytes: 156672
#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)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    if ((X + D - 1) / D > K) {
        cout << X - K * D << endl;
        return 0;
    }
    int tmp = X / D;
    int tmp2 = K - tmp;
    if (tmp2 % 2 == 0) cout << abs(X % D) << endl;
    else cout << abs(X % D - D) << endl;
    return 0;
}


Measured memory_bytes: 3596
N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)

def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))

for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std ;
#define gc getchar
#define ll long long
#define inf 1000009
typedef long long LL;
 LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
 LL Lcm(LL a, LL b) { return (a * (b / gcd(a, b))); }
LL isPrime(LL x)  { ll s = sqrt(x); for (ll i = 2; i <= s; i++) if (x % i == 0) return 0; return 1;} 
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;cin>>s;
    ll n;cin>>n;
    ll rev=0,ch;
    while(n--)
    {
       cin>>ch;
       if(ch==1)rev++;
       else
       {
       	ll df;
       	char c;
       	cin>>df>>c;
       	if(rev%2==0)
       	{
       		if(df==1)s.insert(s.begin(),c);
       		else s.insert(s.end(),c);
       	}
       	else
       	{
       		if(df==2)s.insert(s.begin(),c);
       		else s.insert(s.end(),c);
       	} }
    }
    
    if(rev%2==0)
    cout<<s<<endl;
    else
    {
    	for(ll i=s.length()-1;i>=0;i--)
    	cout<<s[i];
    	cout<<endl;
    }
}
    

	

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int a[12];
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>l;
        a[l]=1;
    }
    for(i=n; ;i++)
    {
        l=i;
        int f=0;
        while(l!=0)
        {
            if(a[(l%10)]==1)
            {
                f=1;
                break;
            }
            l/=10;
        }
        if(f==0)
        {
            cout<<i<<"\n";
            break;
        }
    }
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    if(S[0] != 'A')
    {
        cout << "WA" << endl;
        return;
    }
    int countC = 0, j = 0;
    for(int i = 2; i < S.length()-1; i++) 
        if(S[i] == 'C') 
        {
            countC++;
            j = i;
        }
    if(countC != 1)
    {
        cout << "WA" << endl;
        return;
    }
    for(int i = 1; i < S.length(); i++)
    {
        if(i == j) continue;
        if('A' <= S[i] && S[i] <= 'Z')
        {
            cout << "WA" << endl;
            return;
        }
    }
    cout << "AC" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    float a, b, c, d, e, f, x, y;

    while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF)
    {
        x =(c*e - b*f)/(a*e - b*d);
        y =(a*f - c*d)/(a*e - b*d);
        if(x == -0)
        {
            x = 0;
        }
        if(y == -0)
        {
            y = 0;
        }
        
        printf("%.3f %.3f\n", x, y);

        
    }
    return 0;
}



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

int main(){

	int n, m;
	cin >> n >> m;
	
	int a[100][100] = {};
	
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k; j++){
			int A; cin >> A;
			A--;
			a[i][A] = 1;
		}
	}

	int sum[100] = {};

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			sum[j] += a[i][j];
		}
	}
	
	int ans = 0;
	for(int j = 0; j < m; j++) if(sum[j] == n) ans++;

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

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

int main(){
    int a, b, c; cin >> a >> b >> c;
    int s[3];
    s[0] = a; s[1] = b; s[2] = c;
    sort(s, s+3);
    cout << s[0] + s[1] << endl;
    return 0;
    }

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  sort(ALL(s));
  cout << (s[0] != s[2] ? "Yes\n" : "No\n");
  return 0;
}


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

int main(){
  long long int x;
  cin >> x;
  long long int A_5,B_5;
  for(long long int i=0;i<=1000;i++){
    A_5=i*i*i*i*i;
    
    for(long long int j=-1000;j<=1000;j++){
        B_5=j*j*j*j*j;
        if(A_5-B_5==x){
         
          cout << i << " " << j << endl;
          return 0;
        }
    }
  }
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, x, m;
    cin >> n >> x >> m;
    if(x==0){
        cout << 0 << endl;
        return 0;
    }
    vector<int> flag(1000000, -1);
    flag[x] = 0;
    vector<ll> dp(1000000);
    dp[0] = x;
    ll l = 0, r = 0;
    rep(i, m)
    {
        dp[i + 1] = (dp[i] * dp[i]) % m;
        if (flag[dp[i + 1]] >= 0)
        {
            l = flag[dp[i + 1]];
            r = i + 1;
        }
        flag[dp[i + 1]] = i + 1;
    }
    vector<ll> sum = dp;

    rep(i, m)
    {
        sum[i + 1] += sum[i];
    }

    if (n < l)
    {
        cout << sum[n - 1] << endl;
    }
    else
    {
        ll ans = 0;
        if (l > 0)
        {
            ans += sum[l - 1];
            n -= l;
        }
        ans += (sum[r] - sum[l]) * (n / (r - l));
        if (l > 0)
        {
            ans += sum[l + n % (r - l) - 1] - sum[l - 1];
        }
        else
        {
            ans += sum[l + n % (r - l) - 1];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 22744
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

vector <pi> a[20];

void solve() {
    int n; cin >> n;
    loop(i, n) {
        int sz; cin >> sz;
        loop(j, sz) {
            int x, y;
            cin >> x >> y;
            --x;
            a[i].pb({ x, y });
        }
    }
    int ans = 0;
    loop(mask, (1 << n)) {
        bool ok = 1;
        int sz = 0;
        loop(bit, n)
            if (mask & (1 << bit)) {
                ++sz;
                for (auto p : a[bit])
                    if (bool(mask & (1 << p.F)) != p.S)
                        ok = 0;
            }
        if (ok)
            ans = max(ans, sz);
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000
using ll = long long;

int main(){
  int n,k;
  cin >> n>> k;
  vector<int> a(n);
  rep(i,n)cin>>a.at(i);
  sort(a.begin(),a.end());
  ll ans = 0;
  rep(i,n-k)ans+=a.at(i);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=[format(i,'060b') for i in map(int,input().split())]
ans=0
mod=10**9+7
for k in range(60):
    count=[a[60-1-k] for a in A].count('0')
    ans+=count*(N-count)*(2**k)%mod
print(ans%mod)

Measured memory_bytes: 65708
n, k = map(int, input().split())
num = []
for i in range(n):
    num.append(list(map(int, input().split())))
num.sort()
summ = 0
for i in range(len(num)):
    if k <= summ + num[i][1]:
        print(num[i][0])
        exit()
    else:
        summ += num[i][1]

Measured memory_bytes: 27872
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<tuple<string, int, int>> k;
  rep(i,n){
    string s;
    int t;
    cin >> s >> t;
    k.push_back(make_tuple(s,-t,i+1));
  }
  sort(k.begin(),k.end());
  for(tuple<string, int, int> x: k){
    string z;
    int q;
    int h;
    tie(z, h, q) = x;
    cout << q << endl;
  }
}  


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

void main()
{
    long[] a = readln.chomp.split(" ").to!(long[]);
    long m = long.max;
    foreach (job; [[0, 1, 2], [1, 2, 0], [2, 1, 0], [1, 0, 2], [2, 0, 1]])
    {
        long cost;
        for (long i = 0; i < 2; ++i)
        {
            cost += abs(a[job[i + 1]] - a[job[i]]);
        }
        m = min(m, cost);
    }
    writeln(m);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=1e5+12;
int map[N];int n;
int gcd(int a,int b) 
{
	if(!b) return a;
	return gcd(b,a%b); 
}
int dfs(int x)
{
	int tot=0,flag=1;
	for(int i=1;i<=n;i++) 	
		if(map[i]%2)
		{
			map[i]--;
			break;
		}
	int gc=map[1];
	for(int i=2;i<=n;i++) gc=gcd(gc,map[i]);
	for(int i=1;i<=n;i++)
	{
		map[i]/=gc;
		if(map[i]%2==0) tot++;
		if(map[i]==1) flag=0;
	}
	if(tot%2) return !x;
	if(!flag||n-tot>1) return x;
	dfs(x^1);
	
}
int main()
{	
	scanf("%d",&n);
	int sum=0;
	int sum_flag=0,flag1=1;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&map[i]);
		if(map[i]==1) flag1=0;
		if(map[i]%2==0) sum++;
		else sum_flag++;
//		printf("std:: %d %d %d\n",sum,sum_flag,flag1);
	}
	if(sum%2==1) printf("First\n");
	else
	{
		if(!flag1||sum_flag>=2) printf("Second\n");
		else if(dfs(1)) printf("First\n");
		else printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>
#include <cstdlib>

typedef long long ll;

using namespace std;

int main(void){
	int pa, pb, n;

	while(cin >> n){
		pa = pb = 0;
		if(!n) break;
		for(int i=0; i<n; ++i){
			int c1, c2;
			cin >> c1 >> c2;
			if(c1 > c2){
				pa += c1 + c2;
			}else if(c1 < c2){
				pb += c1 + c2;
			} else {
				pa += c1, pb += c1;
			}
		}

		cout << pa << " " << pb << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	vector<ll> a;
	cin >> n;
	ll k;
	for(ll i=0; i<n; i++){
		cin >> k;
		if(k%2 == 0)
			a.emplace_back(k);
	}
	ll ans = 0;
	for(auto &x : a){
		while(x%2==0){
			x/=2;
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3768
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,m=LI()

g,c=GI(n,m)
def bfs(x):
    v=[0]*n
    q=[x]
    while q:
        c=q.pop()
        v[c]=1
        for nb in g[c]:
            if v[nb]==0:
                q.append(nb)
                v[nb]=1
    return sum(v)

x=min(bfs(0),bfs(1))
print(n*(n-1)//2-x*(n-x)-m)



Measured memory_bytes: 73628
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        string line = Console.ReadLine();
        
        for(int i=0; i<line.Length; i++){
            if(char.IsLower(line[i])){
                Console.Write(char.ToUpper(line[i]));
            }else if(char.IsUpper(line[i])){
                Console.Write(char.ToLower(line[i]));
            }else{
                Console.Write(line[i]);
            }
        }
        Console.WriteLine("");

    }
}
//Fair, later, occasionally cloudy.
//Fair, later, occasionally cloudy.


Measured memory_bytes: 15792
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;


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

  int N; cin >> N;
  int A;
  int res = 1000000000;
  rep(i, N) {
    cin >> A;
    int cnt = 0;
    while(A%2 == 0) {
      A/=2;
      ++cnt;
    }
    res = min(res, cnt);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(' ').map(&:to_i)

abs  = Array.new(m, nil)

for i in 1..m do
  a, b = gets.chomp.split(' ').map(&:to_i)
  abs[i-1] = [a,b]
end

abs.reverse!

def root(array, pos)
  routes = []
  while array[pos] != pos do
    routes.push(pos) # 経路記録
    pos = array[pos]
  end
  for r in routes do
    array[r] = pos
  end
  pos
end

sum = 0
for i in 0..abs.length-1 do
  uf = Array.new(n+1){|index| index}

  for j in 0..abs.length-1 do
    next if i==j
    l,r = abs[j]

    # 左右の根を求める
    l = root(uf, l)
    r = root(uf, r)

    # 根が異なっていれば
    if l != r then  
      # 左の根を右の根につなげる
      uf[l] = r
    end
  end
  roots = 0
  for u in 1..uf.length-1
    roots+=1 if u==uf[u]
  end
  if roots != 1 then
    sum += 1
  end
end

printf("%d\n", sum)

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


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

    ll n;
    string s;
    
    cin>>n>>s;
    int ans = 0;
    for(int i=2;i<n;i++){
        if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")

from bisect import bisect, bisect_left, bisect_right



# Find rightmost value less than x
def find_lt(a, x):
    i = bisect_left(a, x)
    if i:
        return i
    return 0


# Find leftmost value greater than x'
def find_gt(a, x):
    i = bisect_right(a, x)
    if i != len(a):
        return i
    return len(a)


def main():
    N = int(input())
    A = list(sorted(list(map(int, input().split()))))
    B = list(sorted(list(map(int, input().split()))))
    C = list(sorted(list(map(int, input().split()))))

    ans = 0
    for b in B:
        a = find_lt(A, b)
        b = N - find_gt(C, b)
        ans += a * b
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    vector<vector<int>> T(H, vector<int>(W, 0));

    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            cin >> S[i][j];
        }
    }

    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (S[i][j] == '#') continue;

            for (int dy=-1; dy<=1; ++dy) {
                for (int dx=-1; dx<=1; ++dx) {
                    if (dx == 0 && dy == 0) continue;
                    int ny = i + dy;
                    int nx = j + dx;
                    if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
                    if (S[ny][nx] == '#') {
                        ++T[i][j];
                    }
                }
            }
        }
    }
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (S[i][j] == '.')
                cout << T[i][j];
            else
                cout << S[i][j];
        }
        cout << endl;
    }

}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;


bool palin(ll n) {
    if((n/10000)%10==n%10 && (n/1000)%10==(n/10)%10)
        return 1;
    else
        return 0;
}

int main(void) {
    ll a, b;
    cin >> a >> b;
    ll ans=0;
    ll i;
    for(i=a; i<=b; i++) {
        if(palin(i)) {
            ans++;
        }
        
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
res = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            longest = max(L[i], L[j], L[k])
            if longest*2 < L[i] + L[j] + L[k] and len(set([L[i], L[j], L[k]])) == 3:
                res += 1
print(res)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;

  if ((count(s.begin(), s.end(), 'a') == 1) 
      && (count(s.begin(), s.end(), 'b') == 1)
      && (count(s.begin(), s.end(), 'c') == 1)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int[][] a = new int[3][3];

		for(int i = 0;i<3;i++) {
			for(int j= 0;j<3;j++) {

				a[i][j] = scan.nextInt();
			}
		}

		int n = scan.nextInt();
		int[] b = new int[n];
		int[][] check = new int[3][3];

		for(int k=0;k<n;k++) {
			b[k] = scan.nextInt();

			for(int i = 0;i<3;i++) {
				for(int j=0;j<3;j++) {

					if(b[k] == a[i][j]) {
						check[i][j] = 1;
					}
				}
			}
		}

		boolean re = false;

		for(int i=0;i<3;i++) {
			int checkSum = 0;
			for(int j=0;j<3;j++) {
				checkSum += check[i][j];
			}
			if(checkSum == 3) {
				re =true;
			}
		}

		for(int i=0;i<3;i++) {
			int checkSum = 0;
			for(int j=0;j<3;j++) {
				checkSum += check[j][i];
			}
			if(checkSum == 3) {
				re = true;
			}
		}


		int checkSum = 0;
		for(int j=0;j<3;j++) {

			checkSum += check[j][j];
		}
		if(checkSum == 3) {
			re = true;
	}

		checkSum = 0;
		for(int j=0;j<3;j++) {

			checkSum += check[j][2-j];
		}
			if(checkSum == 3) {
				re =true;
		}

		System.out.println(re? "Yes":"No");
		scan.close();
	}

}


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



int main(void)
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    vector<int> success;

    for(int r = 0; r <= K; r++){
        for(int g = 0; g <= K; g++){
            for(int b = 0; b <= K; b++){
                int rval = A * (1 << r);
                int gval = B * (1 << g);
                int bval = C * (1 << b);
                if(rval < gval && gval < bval) success.push_back(r + g + b);
            }
        }
    }

    int min_op = 0;
    if(success.size() > 0){
        min_op = *min_element(success.begin(), success.end());
    } else {
        cout << "No" << endl;
        return 0;
    }

    if(min_op <= K){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
#define MAX 3000

int main(void){
    int x[MAX],y[MAX];
    int i,j;
    
    for(i=0;i<MAX;i++){
        scanf("%d %d",&x[i],&y[i]);
        if(x[i]==0&&y[i]==0){
            break;
        }
        else if(x[i]<0||10000<x[i]||y[i]<0||10000<y[i]){
            printf("error\n");
            return 0;
        }
    }
    
    for(j=0;j<i;j++){
        if(x[j]>y[j]){
            printf("%d %d\n",y[j],x[j]);
        }
        else{
            printf("%d %d\n",x[j],y[j]);
        }
    }
    
    return 0;
}


Measured memory_bytes: 1920
n =int(input())
b =list(map(int, input().split()))

b.insert(n, b[n-2])
b.insert(0, b[0])

a =[]
for i in range(n):
    if b[i] >= b[i+1]:
        a.append(b[i+1])
    else:
        a.append(b[i])
        
print(sum(a))

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int n = 0;
	int input = 0;
	long int sum = 0; 
	int max = -1000001; 
	int min = 1000001;

	CI n;

	for (int i = 0; i < n; ++i) {
		CI input;
		sum += input;
		if (input > max)max = input;
		if (input < min)min = input;
	}

	CO min << " " << max << " " << sum E
}

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

int main(void){
    string s;
    int n, k;
    cin >> n >> s >> k;
    char ex = s[k-1];
    for(int i=0; i<n; i++){
        if(s[i] != ex){
            s[i] = '*';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
s = input()
Q = int(input())

head = ""
tail = ""

reverse = False

for i in range(Q):
    t = input()

    if t[0] == "1":
        reverse = not reverse
    else:
        if t[2] == "1":  # add to the head
            if(reverse):
                tail = tail + t[4]
            else:
                head = t[4] + head
        else:  # add to the tail
            if(reverse):
                head = t[4] + head
            else:
                tail = tail + t[4]

ans = head + s + tail

if(reverse):
    ans = ans[::-1]

print(ans)


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

int main(){
  long long n,ans=1e12;cin>>n;
  for(long long i=1;i*i<=n;i++){
    if(n%i) continue;
    else ans=min(ans,i+n/i-2);
  }
  cout<<ans;
}

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

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int h,w,c;
int p[8][8];

void print(int d){
	cout<<"depth:"<<d<<endl;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)cout<<p[i][j]<<' ';
		cout<<endl;
	}
}
bool all(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			if(p[0][0]!=p[i][j])return false;
	}
	return true;
}
bool in(int y,int x){
	return 0<=y&&y<h&&0<=x&&x<w;
}
int _count(int y,int x,int c){
	if(!in(y,x))return 0;
	if(c!=p[y][x])return 0;	
	int res=1;
	p[y][x]=0;
	for(int i=0;i<4;i++){
		res += _count(y+dy[i],x+dx[i],c);
	}
	return res;
}
bool f(int y,int x,int from,int c,bool visit[8][8]){
	if(!in(y,x))return false;
	if(visit[y][x])return false;
	if(c==p[y][x])return true;
	if(from!=p[y][x])return false;
	visit[y][x]=true;
	for(int i=0;i<4;i++){
		if(f(y+dy[i],x+dx[i],from,c,visit))return true;
	}
	return false;
}
bool neighbor(int c){
	bool visit[8][8];
	memset(visit,false,sizeof(visit));
	return f(0,0,p[0][0],c,visit);
}
void change(int from,int to,int y,int x){
	if(!in(y,x))return;
	if(from!=p[y][x])return;
	p[y][x]=to;
	for(int i=0;i<4;i++){
		change(from,to,y+dy[i],x+dx[i]);
	}
}
int dfs(int depth){//print(depth);
	int res=0;
	if(depth==4){
		if(p[0][0]!=c)change(p[0][0],c,0,0);
		return _count(0,0,c);
	}
	if(all())return h*w;
	int temp[8][8];
	for(int i=1;i<=6;i++){
		if(!neighbor(i) || p[0][0]==i)continue;
		memcpy(temp,p,sizeof(temp));
		change(p[0][0],i,0,0);
		res = max(res,dfs(depth+1));
		memcpy(p,temp,sizeof(temp));
	}
	return res;
}
int main(){
	while(cin>>h>>w>>c,h|w|c){
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)cin>>p[i][j];
		cout<<dfs(0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N,x=0;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    bool f =true;
    while(f==true){
        f = false;
        for(int i = N-1; i > 0; i--){
            if(b[i]<b[i-1]){
                swap(b[i],b[i-1]);
                x++;
                f=true;
            }
        }
    }
    for(int i = 0; i < N-1; i++){
        cout << b[i] <<" ";
    }
    cout <<b[N-1]<< endl;
    cout << x << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(){
  int w, a,b;
  scanf("%d %d %d",&w,&a,&b);
  if(a+w < b){
    printf("%d\n", b-a-w);
  } 
  else if(b+w <a){
    printf("%d\n", a-b-w);
  }
  else 
  printf("0\n");

  return 0;
}

Measured memory_bytes: 128