akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int A[1010];
signed main() {
	int N; cin >> N;
	for(int i=0; i<N; i++) {
		cin >> A[i];
	}
	sort(A, A+N);
	reverse(A, A+N);

	int even = 0, odd = 0;
	for(int i=0; i<N; i++) {
		(i%2 ? odd : even) += A[i];
	}

	cout << even - odd << endl;
    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int res = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] != t[i]) res++;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3828
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL; 																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																							   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL A[100005];
	LL B[100005];
	int n;
	
	cin >> n;
	
	for(int i = 0; i < n+1; i++){
		cin >> A[i];
	}
	for(int i = 0; i < n; i++){
		cin >> B[i];
	}
	
	LL licznik = 0;
	
	for(int i = 0; i < n; i++){
		if(A[i] >= B[i]){
			licznik += B[i];
		}
		else{
			
			licznik += A[i];
			B[i] -= A[i];
			
			if(A[i + 1] >= B[i]){
				A[i + 1] -= B[i];
				licznik += B[i];
			}
			else{
				licznik += A[i + 1];
				A[i + 1] = 0;
			}
		}
		
	
	}
	
	cout << licznik << endl;
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}




Measured memory_bytes: 1792
n = int(input())
list = input().split(" ")
summa = 0
for i in range(n):
  list[i] = int(list[i])
for i in range(n):
  summa = summa + list[i]
if max(list) < (summa - max(list)):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <cmath>
using namespace std;

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

    int sum = 0;
    int mean_s;
    int mean_l;
    for (int i =0; i<N; i++){
        sum += x[i];
    }
    mean_s = sum / N;
    if(mean_s < 1){
        mean_s = 1;
    }else if(mean_s < 100){
        mean_l = mean_s + 1;
    }else{
        mean_l = mean_s;
    }

    int ans1 = 0;
    for (int i =0; i< N; i++){
        ans1 += pow(x[i]-mean_s,2);
    }
    int ans2;
    for (int i =0; i< N; i++){
        ans2 += pow(x[i]-mean_l,2);
    }

    int ans = 0;
    ans = min(ans1,ans2);
    cout << ans <<endl;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

double A,B,C,D,E,F;

int main()
{
	while(~scanf("%lf%lf%lf%lf%lf%lf",&A,&B,&C,&D,&E,&F)){
		double x,y;
		if(A == 0.0){
			y = C / B;
		}
		else if(D == 0.0){
			y = F / E;
		}
		else{
			E -= D / A * B;
			F -= D / A * C;
			D = 0.0;
			y = F / E;
		}
		if(A){
			x = (C - B * y) / A;
		}
		else{
			x = (F - E * y) / D;
		}
		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}

Measured memory_bytes: 3204
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n_line = stdIn.nextInt();
			if(n_line==0){
				return;
			}
			stdIn.nextLine();
			List<String> words = new ArrayList<String>();
			Map<String, Integer> count = new HashMap<String, Integer>();
			for(int i=0;i<n_line;i++){
				String[] line = stdIn.nextLine().split(" ");
				for(int j=0;j<line.length;j++){
					if(words.contains(line[j])){
						int before = count.get(line[j]);
						count.put(line[j], before+1);
					}
					else{
						words.add(line[j]);
						count.put(line[j], 1);
					}
				}
			}
			Collections.sort(words);
			String target = stdIn.next();
			List<String> result = new ArrayList<String>();
			for(int i=0;i<words.size();i++){
				if(words.get(i).startsWith(target)){
					result.add(words.get(i));
				}
			}

			// テスト------------------
//			System.err.println(words.toString());
//			System.err.println(count.toString());
//
//			if(result.size()==0){
//				System.err.println("NA");
//			}
//			else{
//				System.err.print(result.get(0));
//				for(int i=1;i<result.size();i++){
//					if(i==5){
//						break;
//					}
//					System.err.print(" "+result.get(i));
//				}
//				System.err.println();
//			}
			// テスト----------------------

			// 順序整理
			List<String> result2 = new ArrayList<String>();
			int max = 0;
			for(int i=0;i<result.size();i++){
				int temp = count.get(result.get(i));
				if(temp>max){
					max = temp;
				}
			}
//			System.err.println("max="+max);
			for(int i=max;i>=0;i--){
				for(int j=0;j<result.size();j++){
					int temp = count.get(result.get(j));
					if(temp==i){
						result2.add(result.get(j));
					}
				}
			}

			if(result2.size()==0){
				System.out.println("NA");
			}
			else{
				System.out.print(result2.get(0));
				for(int i=1;i<result2.size();i++){
					if(i==5){
						break;
					}
					System.out.print(" "+result2.get(i));
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 41500
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d",a)
using namespace std;
int n;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++) {
	  if (i*i==n) {
	  	out(i*i); return 0;
	  }
	  if (i*i>n) {
	  	out((i-1)*(i-1));
	  	return 0;
	  }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
(n, m) = list(map(int, input().split()))
a = np.array(list(map(int, input().split()))).astype("int64") 
a = np.cumsum(a)
a %= m
count = np.sum(a == 0)
a.sort()
tc = 1
for i in range(1, n):
    if a[i - 1] == a[i]:
        tc += 1
    else:
        count += tc * (tc - 1) // 2
        tc = 1
else:
    count += tc * (tc - 1) // 2
print(count)

Measured memory_bytes: 23108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
ll a, b;
bool ans[4];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> a >> b;
  ans[a] = true;
  ans[b] = true;
  for(int i = 1; i < 4; ++i) {
    if(!ans[i]) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
//2018.9.22 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
namespace MAIN{
    int A,B;
    inline void MAIN(){
        A=read(),B=read();
        if((LL)A*B<=0)puts("Zero");
        else if(A>0&&B>0)puts("Positive");
        else if((B-A)&1)puts("Positive");
        else puts("Negative");
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




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

	int a = 0;
	REP(i, n - 1) {
		if (s[i] == s[i + 1])a++;
	}

	cout << min(a + 2 * k, n - 1) << endl;


}

Measured memory_bytes: 512
import java.util.Scanner;

class Card {
    char m;
    int n;
    int index;

    Card(char m, int n, int index) {
        this.m = m;
        this.n = n;
        this.index = index;
    }    
}

public class Main {
    private static int partition(Card[] a, int p, int r) {
        int x = a[r].n;
        int i = p - 1;
        for(int j = p; j < r; j++) {
            if(a[j].n <= x) {
                i++;
                Card tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
        Card tmp = a[i + 1];
        a[i + 1] = a[r];
        a[r] = tmp;
        return i + 1;
    }

    private static void quickSort(Card[] a, int p, int r) {
        if(p < r) {
            int q = partition(a, p, r);
            quickSort(a, p, q - 1);
            quickSort(a, q + 1, r);
        }
    }

    private static boolean isStable(Card[]a, int n) {
        for(int i = 0; i < n - 1; i++) {
            if(a[i].n == a[i + 1].n && a[i].index > a[i + 1].index) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        Card[] a = new Card[n];
        for(int i = 0; i < n; i++) {
            char m = sc.next().charAt(0);
            int num = sc.nextInt();
            a[i] = new Card(m, num, i);
        }

        quickSort(a, 0, n - 1);

        if(isStable(a, n)) System.out.println("Stable");
        else System.out.println("Not stable");

        for(int i = 0; i < n; i++) {
            System.out.printf("%c %d\n", a[i].m, a[i].n);
        }

        sc.close();
    }
}



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

template <typename T, int B = 3>
class persistent_array {
public:
	static const int mask = (1 << B) - 1;
	struct node {
		T val;
		node* ch[1 << B];
		node() { memset(ch, 0, sizeof(node*) << B); }
		node(T v) : val(v) {}
		node(node* t) { memcpy(ch, t->ch, sizeof(node*) << B); }
	};
private:
	const int h, n;
	const T id;
	node *root;
	int get_h(int n) {
		int cnt = 0, tmp = 1;
		while (tmp < n) tmp <<= B, cnt++;
		return cnt;
	}
	node* fix(node *t, int p, T val, int x) {
		if (x < 0) return new node(val);
		t = t ? new node(t) : new node();
		int to = (p >> x) & mask;
		t->ch[to] = fix(t->ch[to], p, val, x - B);
		return t;
	}
	node* dfs(int p, int d, const vector<T>& v) {
		if ((int)v.size() <= (p << d)) return nullptr;
		if (d == 0) return new node(v[p]);
		node* t = new node;
		for (int i = 0; i < (1 << B); i++) {
			t->ch[i] = dfs((p << B) | i, d - B, v);
		}
		return t;
	}
	node* init(const vector<T>& v) {
		return dfs(0, h * B, v);
	}
public:
	persistent_array(int n_, T id_ = 0)
		: h(get_h(n_)), n(1 << (h * B)), id(id_), root(nullptr) {}
	persistent_array(const vector<T>& v, T id_ = 0)
		: h(get_h(v.size)), n(1 << (h * B)), id(id_), root(init(v)) {}
	T set(int p, T val) {
		root = fix(root, p, val, B * (h - 1));
		return val;
	}
	T operator[](int p) const {
		node* t = root;
		for (int i = (h - 1) * B; i >= 0; i -= B) {
			if (!t) return id;
			t = t->ch[(p >> i) & mask];
		}
		return t ? t->val : id;
	}
	void trip_version(node* ver) {
		root = ver;
	}
	node* get_version() const {
		return root;
	}
};

class persistent_union_find {
public:
	using pa = persistent_array<int>;
	using node = typename pa::node;
private:
	pa par;
	int find(int a) {
		return par[a] < 0 ? a : par.set(a, find(par[a]));
	}
public:
	persistent_union_find(int n) : par(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] > par[b]) swap(a, b);
		par.set(a, par[a] + par[b]);
		par.set(b, a);
	}
	int size(int a) {
		return -par[find(a)];
	}
	void trip_version(node* ver) {
		par.trip_version(ver);
	}
	node* get_version() {
		return par.get_version();
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	persistent_union_find uf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else {
			printf("%d\n", uf.same(x, y));
		}
	}
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  int ans = 0;
  
  for(int i = 0; i < n-2; i++){
    if((p.at(i)<p.at(i+1) && p.at(i+1)<p.at(i+2)) || (p.at(i)>p.at(i+1) && p.at(i+1)>p.at(i+2))){
      ans++;
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main(void)
{
    int x;
    cin >> x;
    int a = x / 1000;
    int b = x % 1000 / 100;
    int c = x % 100 / 10;
    int d = x % 10;

    if(a+b+c+d==7){
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a - b + c + d == 7)
    {
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a + b - c + d == 7){
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a + b + c - d == 7){
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a - b - c + d == 7){
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a - b + c - d == 7){
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a + b - c - d == 7){
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
        return 0;
    }
    else if (a - b - c - d == 7){
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
        return 0;
    }

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  cout << N*800 - (N/15)*200 << endl;
  return 0;
}


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

int main(){
  long int a, b, n;
  cin >> n >> a >> b;
  long int out = (n * b - b + a) - (n * a - a + b) + 1;
  if(n == 1){
    if(a == b){
      out = 1;
    }else{
      out = 0;
    }
  }
  if(a > b){
    out = 0;
  }
    
  cout << out;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	bool t[4]={false};
	if(a.size()>=6)t[0]=true;
	for(int i=0;i<a.size();i++){
		if(a[i]>='0'&&a[i]<='9')t[1]=true;
		if(a[i]>='A'&&a[i]<='Z')t[2]=true;
		if(a[i]>='a'&&a[i]<='z')t[3]=true;
	}
	if(t[0]+t[1]+t[2]+t[3]==4)cout<<"VALID"<<endl;
	else cout<<"INVALID"<<endl;
	return 0;
}

Measured memory_bytes: 1180
Scanf.scanf "%d %d" (fun h w ->
    let hist = Array.make 26 0 in
    for i = 1 to h do
        Scanf.scanf " %s" (fun s ->
            String.iter (fun c ->
                let q = int_of_char c - 97 in
                hist.(q) <- hist.(q) + 1
            ) s
        )
    done;
    let e4, e2, e1 =
        Array.fold_left (fun (e4, e2, e1) v ->
            if v mod 4 = 0 then (e4 + 1, e2, e1) else
            if v mod 2 = 0 then (e4, e2 + 1, e1) else
                                (e4, e2, e1 + 1)
        ) (0, 0, 0) hist
    in
    let mode = (h mod 2) * 2 + (w mod 2) in
    print_endline @@ if mode = 0 then (if e2 + e1 > 0 then "No" else "Yes") else
                     if mode = 3 then (if e1 = 1 && e2 <= (w + h - 2) / 2 then "Yes" else "No") else
                     if mode = 2 then (if e1 = 0 && e2 <= w / 2 then "Yes" else "No") else
                                      (if e1 = 0 && e2 <= h / 2 then "Yes" else "No")
)

Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[100100][13];

int main(void){
	int n,i,j,k;
	string s;
	cin >> s;
	n = s.l_ength();
	dp[0][0] = 1ll;
	for(i=0; i<n; ++i){
		if(s[i]=='?'){
			for(j=0; j<13; ++j){
				for(k=0; k<10; ++k){
					add_mod(dp[i+1][(j*10+k)%13],dp[i][j]);
				}
			}
		}else{
			s[i] -= '0';
			for(j=0; j<13; ++j){
				add_mod(dp[i+1][(j*10+s[i])%13],dp[i][j]);
			}
		}
	}
	cout << dp[n][5] << endl;
	return 0;
}


Measured memory_bytes: 10624
n = int(input())
t, a = map(int,input().split())
array = list(map(lambda x: abs(a - (t - int(x) * 0.006)),input().split()))
cnt = 0
Min = 9999
for i in range(n):
    if Min > array[i]:
        Min = array[i]
        cnt = i + 1
print(cnt)

Measured memory_bytes: 3064
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	if (b-1) < (n-a):
		ans = min(n-a, b-1, a+(b-a-1)//2)
	else:
		ans = min(n-a, b-1, n-b+1+(b-a-1)//2)
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
using namespace std;

string str;
int ans = inf;
bool vis[30];

bool jg(int b, string a)
{
    for(int i = 0;i < a.length();i++)
    {
        if(a[i] - 'a' != b)
            return false;
    }
    return true;
}

string get2(int a, string str2)
{
    for(int i = 0;i < str2.length() - 1;i++)
    {
        if(str2[i] - 'a' == a||str2[i + 1] - 'a' == a)
            str2[i] = a + 'a';
    }
    str2.erase(str2.end() - 1);
    return str2;
}

void get(int a, string str2)
{
    int res = 0;
    while(1)
    {
        if(jg(a, str2))
        {
            ans = res;
            break;
        }
        res++;
        str2 = get2(a, str2);
        if(res >= ans)
            break;
    }
}

int main()
{
    cin>>str;
    for(int i = 0;i < str.length();i++)
        vis[str[i] - 'a'] = 1;
    for(int i = 0;i < 26;i++)
    {
        if(vis[i])
            get(i, str);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
D = int(input())
c = [int(_) for _ in input().split()]
s = [[int(_) for _ in input().split()] for _ in range(D)]

sat = 0
last = [0] * 26
for d in range(D):
    v = 0
    j = 0
    for x in range(26):
        if v < s[d][x]:
            j = x
            v = s[d][x]
    last[j] = d + 1
    print(j+1)

    for i in range(26):
        sat -= (d + 1 - last[i]) * c[i]
    sat += s[d][j]
    # print(sat)


Measured memory_bytes: 9500
#include <stdio.h>
#include <string.h>
 
int main () {
	char str[255], temp[255];
	scanf("%s", str);
	
	for (int i = 0, j = 0 ; str[i] != '\0' ; i++) {
		if(str[i] == '1') {
			temp[j] = '1';
			j++;
			temp[j] == '\0';
		} else if(str[i] == '0') {
			temp[j] = '0';
			j++;
			temp[j] = '\0';
		} else {
			if ( j > 0) {
				temp[--j] = '\0';
			}
		}
	}
	printf("%s", temp);
	return 0;
}

Measured memory_bytes: 1712
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,h = LI()
    a = []
    b = []
    for _ in range(n):
        c,d = LI()
        a.append(c)
        b.append(d)
    ma = max(a)
    b = sorted(b, reverse=True)
    r = 0
    for c in b:
        if c <= ma:
            break
        r+=1
        h-=c
        if h<=0:
            return r

    r += h//ma
    if h%ma!=0:
        r += 1
    return r

print(main())




Measured memory_bytes: 14640
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;

  if(a==b) cout << "Draw" << endl;
  else if(a > b) cout << "Alice" << endl;
  else cout << "Bob" << endl;

  return 0;
}


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

int main(){
  int a,b,c,temp;
  cin >> a >> b >> c;
  
  if (a > b){
    temp = a;
    a = b;  
    b = temp;
   }
  
  if (b > c){
    temp = b;
    b = c;
    c = temp;

  }

  if (a > b){
    temp = a;
    a = b;  
    b = temp;
   }

  cout << a << " " << b << " " << c << endl;
  

  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main() {
    float x1, x2, x3, x4;
    float y1, y2, y3, y4;
    int n;
    
    scanf("%d", &n);
    while (n-- > 0) {
        scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        if ((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3) == 0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

string s;
int bs=1, M=1e9+7, d[100005][15]={1};
int main() {
	int i, j, k, t;
	cin>>s;
	reverse(s.begin(), s.end());
	for(i=1; i<=s.size(); i++) {
		if(s[i-1] != '?') {
			t = (s[i-1] - '0') * bs % 13;
			for(j=0; j<13; j++) d[i][(j+t)%13] = (d[i][(j+t)%13] + d[i-1][j]) % M;
		} else {
			for(k=0; k<10; k++) {
				t = k * bs % 13;
				for(j=0; j<13; j++) d[i][(j+t)%13] = (d[i][(j+t)%13] + d[i-1][j]) % M;
			}
		}
		bs = (bs * 10) % 13;
	}
	cout<<d[s.size()][5];
	return 0;
}

Measured memory_bytes: 6272
#include<stdio.h>
int main(){
	int n,i;
	float x1,y1,x2,y2,x3,y3,x4,y4;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if(((y2-y1)/(x2-x1))==((y4-y3)/(x4-x3))){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

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

Measured memory_bytes: 256
import itertools
a=set([0,1,2,3,4,5,6,7,8,9])
n,_=map(int,input().split())
b=map(int,input().split())
l=len(str(n))
c=set(b)^a
for i in range(l,l+2):
    for x in itertools.product(c,repeat=i):
        d=''.join(map(str,x))
        if int(d)>=n:print(d);exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
int n;

ll ans;
int main() {
	ll a,b;
	cin>>a>>b;
	if((a+b)&1) {
		cout<<"IMPOSSIBLE"; 
	}else{
		cout<< ((a+b)>>1 )<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    if A[0] > 0:
        print(-1)
        return
    ans = 0
    for i in range(1,N):
        # print(i, A[i])
        if A[i] == 0:
            continue
        if A[i] == 1:
            ans += 1
            continue
        if A[i] == A[i-1]+1:
            ans += 1
            continue
        if A[i] <= A[i-1]:
            ans += A[i]
            continue
        print(-1)
        return
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 17068
#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() {
	int n;
	cin >>n;
	n = n%10;
	if(n==3)cout<<"bon";
	else if(n==0||n==1||n==6||n==8)cout<<"pon";
	else cout<<"hon";
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using tuplis = array<ll, 3>;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef long double ld;
#define print(out) cout<< out  << "\n";
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for(auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(all(__VA_ARGS__),0LL)
#define dsum(...) accumulate(all(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
const int MOD=1000000007;
const int INF = 1e9;
const ld EPS=1e-9;
template<class T> inline auto max(const T& a){ return *max_element(all(a)); }
template<class T> inline auto min(const T& a){ return *min_element(all(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

vector<int> visited;
vector<int> num;
int idx;

void dfs(int i,const vector<vector<int>> &G,int &cnt){
  cnt++;
  visited[i]=idx;
  each (j,G[i]){
    if(visited[j]==-1){
      dfs(j,G,cnt);
    }
  }
}

int main(){
  int N,M,K,a,b;cin>>N>>M>>K;
  vector<vector<int>> F(N);
  vector<int> B1(K,0),B2(K,0);

  REP(i,0,M){
    cin>>a>>b;
    a--;b--;
    F[a].push_back(b);
    F[b].push_back(a);
  }
  REP(i,0,K){
    cin>>a>>b;
    a--;b--;
    B1[i]=b;B2[i]=a;
  }

  visited.assign(N,-1);
  idx=0;

  REP(i,0,N){
    if(visited[i]==-1){
      int cnt=0;
      dfs(i,F,cnt);
      num.push_back(cnt);
      idx++;
    }
  }
  vector<int> ans(N);
  REP(i,0,N){ans[i]=num[visited[i]]-(int)F[i].size()-1;}
  REP(i,0,K){
      if (visited[B1[i]] == visited[B2[i]]) {
          ans[B1[i]]--;
          ans[B2[i]]--;
      }
  }

  REP(i,0,(int)ans.size()){
    cout << ans[i];
    cout << " ";
    }
    cout << endl;
    return 0;

}


Measured memory_bytes: 8832
using System;

 class Program
 {
     static void Main(string[] args)
     {
         double data1, data2, data3,data4,data5,temp;
         double[] result = new double[3];
         String nyuryoku;
         nyuryoku = Console.ReadLine();
         string[] data = nyuryoku.Split(' ');
         data1 = Double.Parse(data[0]); 
         data2 = Double.Parse(data[1]);
         data3 = Double.Parse(data[2]);
         data4 = Double.Parse(data[3]);
         data5 = Double.Parse(data[4]);

         if ((data3 - data5) < 0)
         {
             Console.WriteLine("No");
             return;
         }
         if ((data4 - data5) < 0)
         {
             Console.WriteLine("No");
             return;
         }
         if((data3 + data5) > data1)
         {
             Console.WriteLine("No");
             return;
         }
         if((data4 + data5) > data2)
         {
             Console.WriteLine("No");
             return;
         }
         Console.WriteLine("Yes");
                     }
 }



Measured memory_bytes: 17952
#include <stdio.h>

int main(void) {
  int N,K = 0;
  scanf("%d %d",&N,&K);
  int PList[N];
  int CList[N];
  int i = 0;
  for(i=0;i<N;i++){
    scanf("%d", &PList[i]);
  }
  for(i=0;i<N;i++){
    scanf("%d", &CList[i]);
  }
  long long ans = -1e18;
  int si = 0;  
  for(si=0; si<N; si++){
    int x = si;
    int s[N];
    long long total = 0;
    long long l = 0;
    int idx = -1;
    while(1){
      x = PList[x]-1;
      s[++idx] = CList[x];
      l += 1;
      total += CList[x];
      if (x == si){
        break;
      }
    }
    long long t = 0;
    for (i=0;i<l;i++){
      t += s[i]; 
      if (i+1 > K){
        break;
      }
      long long now = t;
      if (total > 0){
        long long e = (K-(i+1))/l;
        now += total*e;
      }
      if (ans<now){
        ans = now;
      }
    }
  }
  printf("%lld", ans);
  return 0; 
}

Measured memory_bytes: 1776
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	T := make([]int, N)
	lcm := 1
	for i := 0; i < N; i++ {
		T[i] = getInt()
		lcm = LCM(lcm, T[i])
	}
	out(lcm)
}


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

int main() {
    int N;
    cin >> N;
    map<char, int> mp;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        mp[S[0]]++;
    }

    vector<ll> cnt(5, 0);
    cnt[0] = mp['M'];
    cnt[1] = mp['A'];
    cnt[2] = mp['R'];
    cnt[3] = mp['C'];
    cnt[4] = mp['H'];

    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
vector<int> graph[606];
double ans = HINF<LL>();
double dp[606];
double solve(int pass){
    dp[n] = 0;
    for(int i = n - 1;i >= 0;i--){
        double sum = 0.0, maxl = 0.0;
        int num = (int)graph[i].size();
        for(auto to: graph[i]){
            sum += dp[to];
            maxl = max(maxl, dp[to]);
        }
        if(i == pass && num >= 2){
            num--;
            sum -= maxl;
        }
        dp[i] = sum / num + 1;
    }
    return dp[1];
}

int main(){
    cin >> n >> m;
    REP(i, m){
        int s, t;
        cin >> s >> t;
        graph[s].emplace_back(t);
    }
    REP(i, n)ans = min(ans, solve(i));
    cout << fixed << setprecision(13) << ans << endl;
}

Measured memory_bytes: 1408
import Control.Monad
import Data.Function
import Data.Char
import Data.List
import Text.Read
import Text.ParserCombinators.ReadPrec

import Data.Array as A
import Data.Array.MArray as A
import Data.Array.ST as A

newtype Pair a b = Pair { getPair :: (a, b) }

instance (Read a, Read b) => Read (Pair a b) where
  readPrec = Pair `dot` (,) <$> readPrec <* get <*> readPrec

instance (Show a, Show b) => Show (Pair a b) where
  show (Pair (a, b)) = show a ++ " " ++ show b

infixr 8 `dot`
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  n <- readLn
  let f = solve n
  mapM_ print $ map (f A.!) [1..n]

solve :: Int -> A.Array Int Int
solve n = A.runSTArray $ do
  let m = ceiling $ sqrt $ fromIntegral n
  f <- A.newArray (1, n) 0
  forM_ ((,,) <$> [1..m] <*> [1..m] <*> [1..m]) $ \(x, y, z) -> do
    let i = x^2 + y^2 + z^2 + x*y + y*z + z*x
    when (i <= n) $ do
      f_i <-A.readArray f i
      A.writeArray f i (f_i + 1)
  return f 


Measured memory_bytes: 16792
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200016
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
int n , m , k;
int A[MAXN] , nm[MAXN];
bool apl( char* s , int l ) {
    for( int i = 0 ; i < l ; ++ i ) {
        if( s[i] != s[l - i - 1] ) return false;
    }
    return true;
}
char str[MAXN];
void solve( ) {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%d",&A[i]) , ++ nm[A[i]];
    long long res = 0;
    for( int i = 1 ; i <= n ; ++ i ) res += 1ll * ( nm[i] - 1 ) * nm[i] / 2;
    for( int i = 1 ; i <= n ; ++ i ) {
        res -= 1ll * ( nm[A[i]] - 1 ) * nm[A[i]] / 2;
        -- nm[A[i]];
        res += 1ll * ( nm[A[i]] - 1 ) * nm[A[i]] / 2;
        printf("%lld\n",res);
        res -= 1ll * ( nm[A[i]] - 1 ) * nm[A[i]] / 2;
        ++ nm[A[i]];
        res += 1ll * ( nm[A[i]] - 1 ) * nm[A[i]] / 2;
    }
}
signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 3712
from collections import deque
N=int(input())
ans=[]
d=deque()
i=0
cnt=0
d.append(3)
d.append(5)
d.append(7)
while i<50000:
    v=d.popleft()
    buf=list(str(v))
    if len(set(buf))==3:
        ans.append(v)
    d.append(v*10+3)
    d.append(v * 10 + 5)
    d.append(v * 10 + 7)
    #print(ans,d)
    #input()
    i=i+1
for i in range(len(ans)):
    if N>=ans[i]:
        cnt=cnt+1
    else:
        break
print(cnt)

Measured memory_bytes: 46812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n;
		try(Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
		}
		long sum = 0;
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				for(int k = 1; k <= n; k++) {
					sum += gcd(i, j, k);
				}
			}
		}
		System.out.println(sum);
	}


	private static int gcd(int a, int b, int c) {
		while(true) {
			int gcd = gcd(b, c);
			int tmp = a % gcd;
			if(tmp == 0) {
				return gcd;
			}
			
			a = b;
			b = c;
			c = tmp;
		}
	}
	private static int gcd(int a, int b) {
		int tmp;
        while ((tmp = a % b) != 0) {
            a = b;
            b = tmp;
        }
        return b;
	}
}


Measured memory_bytes: 35708
#include <stdio.h>

int euclid(int a, int b)
{
    int temp;

    if (a < b) {
        temp = a;
        a = b;
        b = temp;
    }
    if (b < 1) {
        return -1;
    }

    if (a % b == 0) {
        return b;
    }
    return euclid(b, a % b);
}

int main(void) {
    int K;
    scanf("%d", &K);

    int result = 0;
    int num = 0;
    int i;
    int a, b, c;
    for (a = 1; a <=K; a++) {
        for (b = 1; b <= K; b++) {
            for (c = 1; c <= K; c++) {
                num = euclid(a, b);
                num = euclid(num, c);
                result += num;
            }
        }
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 2148
main(){long long A,B,C,D,E,F;scanf("%ld%ld%ld",&A,&B,&C);
D=(A%2)*B*C;E=A*(B%2)*C;F=A*B*(C%2);E<D&&(D=E);F<D&&(D=F);
printf("%ld\n",D);}

Measured memory_bytes: 128
#include <stdio.h>
 
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 2048
from functools import reduce
N, M = list(map(int, input().split()))
ps_list = [input().split() for _ in range(M)]

result = {}
for row in ps_list:
  if not row[0] in result:
    result[row[0]] = {
        "AC": 0,
        "WA": 0
    }
  if result[row[0]]["AC"] > 0:
    continue
  else:
    result[row[0]][row[1]] = result[row[0]][row[1]] + 1

ac = 0
wa = 0
for k,v in result.items():
  ac = ac + v["AC"]
  if v["AC"] == 0:
    continue
  wa = wa + v["WA"]
print(ac, wa)

Measured memory_bytes: 68652
import java.util.Scanner;

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

			String S= scan.next();
			char[]s = S.toCharArray();
			String T = scan.next();
			char[]t = T.toCharArray();

			int[][]dp = new int[s.length+1][t.length+1];

			for(int i = 1;i<=s.length;i++) {
				for(int j = 1;j<=t.length;j++) {
					if(s[i-1]==t[j-1]) {
						dp[i][j] = dp[i-1][j-1]+1;
					}else {
						dp[i][j] =  Math.max(dp[i-1][j], dp[i][j-1]);
					}
				}
			}


			int len =  dp[s.length][t.length];
			StringBuffer sb = new StringBuffer();
			int i = s.length;
			int j = t.length;

			while(len>0) {
				if(s[i-1]==t[j-1]) {
					sb.append(s[i-1]);
					i--;
					j--;
					len--;
				}else if(dp[i][j]==dp[i-1][j]){
					i--;
				}else {
					j--;
				}

			}

			String ans = sb.reverse().toString();

			System.out.println(ans);









		}


	}


}


Measured memory_bytes: 85868
#include<bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    bool easy = true;
    for (int i = 0; i < 3; i++) {
        if (S[i] == S[i+1]){
            easy = false;
            break;
        } 
    }
    if (easy) {
        cout << "Good";
    }else {
        cout << "Bad";
    }


}

Measured memory_bytes: 256
n = gets.chomp.to_i
d = gets.chomp.split(" ").map(&:to_i).sort!
m = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i).sort!

ctr = 0

t.each do |k|
  while k != d[ctr]
    ctr += 1
    if ctr > d.size
      puts "NO"
      exit
    end
  end
  ctr += 1
end
puts "YES"





Measured memory_bytes: 36324
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
  
using namespace std;

/********** TEMPLATE STARTS HERE ***********/
  
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
  
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
  
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
 
/*********** TEMPLATE ENDS HERE *************/

main()
{
	IOS
	int a, b;
	cin >> a >> b;
	if(a == 2 || b == 2)
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 896
def main(argv)
  n = gets.chomp.to_i
  a = gets.chomp.split(' ').map(&:to_i)
  b = gets.chomp.split(' ').map(&:to_i)
  c = gets.chomp.split(' ').map(&:to_i)
  
  s = 0
  
  n.times do |i|
    s += b[a[i] - 1]
  end
  
  (n - 1).times do |i|
    if a[i] + 1 == a[i + 1] then
      s += c[a[i] - 1]
    end
  end
  
  puts s.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
int main() {
  string in(s); string in(t);

  int N = s.size(), M = t.size();
  int dp[N+1][M+1];
  rep(i, N+1) rep(j, M+1) dp[i][j] = 0;

  rep(i, N) rep(j, M) {
    if (s[i] == t[j])
      dp[i+1][j+1] = dp[i][j] + 1;
    else
      dp[i+1][j+1] = max(dp[i][j], max(dp[i+1][j], dp[i][j+1]));
  }
  string ans;
  int m = M;
  int lcs = dp[N][M];
  rrep(i, N) {
    if (dp[i][m] != lcs) {
      ans += s[i];
      --lcs;
      while (m-1 >= 0 && dp[i][m-1] == lcs)
        --m;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

string s;
bool flag = true;

int main() {

	cin >> s;

	if (s.size() % 2 == 0) {
		rep(i, s.size()) {
			if (i % 2 == 0) {
				if (s[i] != 'h') {
					cout << "No" << endl;
					flag = false;
					break;
				}
			}
			else {
				if (s[i] != 'i') {
					cout << "No" << endl;
					flag = false;
					break;
				}
			}
		}
	}
	else {
		cout << "No" << endl;
		flag = false;
	}

	if (flag)cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256