akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<double> vd;
	for(int i=0;i<n;i++)
	{
		double a;
		cin>>a;
		vd.push_back(a);
	}
	while(vd.size()>1)
	{
		sort(vd.begin(),vd.end());
		double a,b;
		a = vd[0];b = vd[1];
		vd.erase(vd.begin()+0);
		vd.erase(vd.begin()+0);
		double k = (a+b)/2;
		vd.push_back(k);
	}
	cout<<vd[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int a, b, c, n;
	cin >> a >> b >> c >> n;
	int x, y;
	x = n / a;
	y = n / b;
	int cnt;
	cnt = 0;
	for (int i = 0; i <= x; i++)
	{
		if (a * i == n)
		{
			cnt++;
			break ;
		}
		for (int j = 0; j <= y && a * i + b * j <= n; j++)
		{
			if (a * i + b * j == n)
			{
				cnt++;
				break ;
			}
			if ((n - (a * i + b * j)) % c == 0)
				cnt++;
		}
	}
	cout << cnt << endl;
}
// END

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


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
using vi=vector<ll>;
using vvi=vector<vi>;
template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
struct UnionFind {
  vi d;
  UnionFind(ll n=0):d(n,-1) {}
  ll find(ll x){
    if(d[x]<0) return x;
    return d[x]=find(d[x]);
  }
  bool unite(ll x,ll y) {
    x=find(x); y=find(y);
    if(x==y) return false;
    if(d[x]>d[y]) swap(x,y);
    d[x]+=d[y];
    d[y]=x;
    return true;
  }
  bool same(ll x,ll y) {return find(x)==find(y);}
  ll size(ll x) {return -d[find(x)];}
};
vi p(100005),q[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,k;
  cin>>n>>m>>k;
  UnionFind uf(n);
  //friend
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    p[a]++; p[b]++;
    uf.unite(a,b);
  }
  //block
  rep(i,k){
    ll c,d;
    cin>>c>>d;
    c--; d--;
    q[c].eb(d); q[d].eb(c);
  }
  vi ans;
  rep(i,n){
    ll x=uf.size(i)-p[i]-1;
    for(ll k:q[i]){if(uf.same(i,k)) x--;}
    ans.eb(x);
  }
  outv(ans);
}


Measured memory_bytes: 9976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			if ((0 == (k % 2)) || (0 == (k % 5))) {
				System.out.println(-1);
				return;
			}
			System.out.println(getResult(k));
		}
	}

	/**
	 * 7,77,777,… という数列の中に初めてkの倍数が登場するのは何項目を計算する
	 * 
	 * @param k k
	 * @return 7,77,777,… という数列の中に初めてkの倍数が登場するのは何項目
	 */
	private static int getResult(int k) {
		if (0 == (k % 7)) {
			k /= 7;
		}
		long now = 1L;
		for (int i = 1;; i++) {
			if (0 == (now % k)) {
				return i;
			}
			now = (now * 10 + 1) % k;
		}
	}
}


Measured memory_bytes: 35556
N,M,X=map(int,input().split())
A_LIST=input().split()

for i in range(len(A_LIST)):
    A_LIST[i]=int(A_LIST[i])

left_counter=0
right_counter=0

for i in A_LIST:
    if i<X:
        left_counter+=1
    else:
        right_counter+=1

print(left_counter if left_counter<right_counter else right_counter)

Measured memory_bytes: 3060
n = int(input())
balls = []
for i in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

dic = {}

for i in range(n):
    for j in range(n):
        if i != j:
            coordinate = str((balls[i][0] - balls[j][0], balls[i][1] - balls[j][1]))
            if coordinate in dic:
                dic[coordinate] += 1
            else:
                dic[coordinate] = 1

dic = sorted(dic.items(), key = lambda x: x[1], reverse = True)
if len(dic) == 0:
    print(n)
else:
    print(n - dic[0][1])


Measured memory_bytes: 39664
#include<iostream>
#include<string>
#include<map>
#include<queue>
using namespace std;




int main(){
	
	string tmp="01234567";
	queue<string>bfs;
	map<string,int>table;

	bfs.push(tmp);


	table[tmp]=0;	
	while(!bfs.empty()){
		string tmp=bfs.front();
		bfs.pop();
		string next;

		for(int i=0;i<4;i++){
			next=tmp;
			if(next[i]!='0'&&next[i+4]!='0')continue;
			swap(next[i],next[i+4]);
			if(table[next]!=0)continue;
			table[next]=table[tmp]+1;
			bfs.push(next);
		}

		for(int i=0;i<3;i++){
			next=tmp;
			if(next[i]!='0'&&next[i+1]!='0')continue;
			swap(next[i],next[i+1]);
			if(table[next]!=0)continue;
			table[next]=table[tmp]+1;
			bfs.push(next);
		}

		for(int i=0;i<3;i++){
			next=tmp;
			if(next[i+4]!='0'&&next[i+5]!='0')continue;
			swap(next[i+4],next[i+5]);
			if(table[next]!=0)continue;
			table[next]=table[tmp]+1;
			bfs.push(next);
		}
	}
	//?????????????´??????????0
	table["01234567"]=0;

	char x;
	while(cin>>x){
		string ans="";
		ans.push_back(x);
		for(int i=0;i<7;i++){
			cin>>x;
			ans.push_back(x);
		}
		cout<<table[ans]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3444
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    C=Counter(input())
    if(len(C)!=2):
        print("No")
        return
    for k,v in C.items():
        if(v!=2):
            print("No")
            return
    print("Yes")
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR(i, beg, end) for (int i = beg; i < end; i++)

using namespace std;

struct Point {
	int x;
	int y;
};

void add(const vector<vector<bool>>& map, vector<vector<int>>& values, queue<Point>& search, int x, int y, int w, int h, int val)
{
	if (x < 0 || w <= x || y < 0 || h <= y) return;
	if (!map[x][y]) return;
	if (values[x][y] != -1) return;

	values[x][y] = val;
	search.push({ x,y });
}

int solve(const vector<vector<bool>>& map, int w, int h)
{
	vector<vector<int>> values(w, vector<int>(h, -1));

	queue<Point> search;
	search.push({ 0,0 });
	values[0][0] = 1;

	while (!search.empty()) {
		Point cur = search.front();
		search.pop();

		if (cur.x == w - 1 && cur.y == h - 1) return values[cur.x][cur.y];

		int next_val = values[cur.x][cur.y] + 1;
		add(map, values, search, cur.x + 1, cur.y + 0, w, h, next_val);
		add(map, values, search, cur.x - 1, cur.y + 0, w, h, next_val);
		add(map, values, search, cur.x + 0, cur.y + 1, w, h, next_val);
		add(map, values, search, cur.x + 0, cur.y - 1, w, h, next_val);
	}

	return -1;
}

int main()
{
	int h, w; cin >> h >> w;

	vector<vector<bool>> map(w, vector<bool>(h, false));

	int num_spaces = 0;
	FOR(y, 0, h) {
		FOR(x, 0, w) {
			char c; cin >> c;

			if (c == '#') continue;

			map[x][y] = true;
			num_spaces++;
		}
	}

	int count_path = solve(map, w, h);

	if (0 < count_path) {
		cout << (num_spaces - count_path) << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)

int conv(int y, int m, int d) {
	int dd = 0;
	FOR(yy, 1, y) {
		if(yy%3 == 0) {
			dd += 200;
		} else {
			dd += 195;
		}
	}

	FOR(mm, 1, m) {
		if(y%3 == 0) {
			dd += 20;
		} else {
		if(mm%2 == 0) {
			dd += 19;
		} else {
			dd += 20;
		}
		}
	}

	dd += d;
	return dd;
}

int main() {
	int n;
	cin >> n;
	int Y, M, D;
	int mille = conv(1000, 1, 1);
	REP(i, n) {
		cin >> Y >> M >> D;
		int day = conv(Y, M, D);
		cout << mille-day << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
 #include<iostream>
using namespace std;
const int mod=1e9+7;
const int MAX=1e9+7;
int a[105];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int k=0,t=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			k++;
			if(a[i]%3==0||a[i]%5==0)
			t++;
		}
	}
	if(t==k)
	cout<<"APPROVED";
	else cout<<"DENIED";
	
}


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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

struct vertex {
  // vector<vertex*> edge;
  set<int> edge;
  int cnt = 0;
  bool visited = false;
};

vertex G[202020];

int counter[202020];

void dfs(int root) {
  G[root].visited = true;
  counter[root] = G[root].cnt;
  for (auto i : G[root].edge) {
    if (G[i].visited) continue;
    G[i].cnt += counter[root];
    dfs(i);
  }
}

int main() {
  int N, Q;
  cin >> N >> Q;
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].edge.insert(b);
    G[b].edge.insert(a);
  }
  for (int i = 0; i < Q; ++i) {
    int p, q;
    cin >> p >> q;
    G[p].cnt += q;
  }
  dfs(1);
  for (int i = 1; i < N; ++i) cout << counter[i] << " ";
  cout << counter[N] << endl;
}

Measured memory_bytes: 42368
#include<stdio.h>
int main(void)
{
    int i,a[5],b[5],c,d;
	char mise[5]={'A','B','C','D','E'};
	while(1){
	    c=0;
		scanf("%d %d",&a[0],&b[0]);
	    if(a[0]==0&&b[0]==0) break;
		for(i=1;i<5;i++){
		    scanf("%d %d",&a[i],&b[i]);
		}
		for(i=0;i<5;i++){
		    if(c<a[i]+b[i]){
			    c=a[i]+b[i];
				d=i;
			}
		}
		printf("%c %d\n",mise[d],c);
	}
	return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  string s;
  cin >> s;
  int x, y; cin >> x >> y;

  vector<int> xx, yy;
  int dir = 0; // x方向
  int cnt = 0;
  yy.push_back(0);

  for (char c : s) {
    if (c == 'F') cnt++;
    if (c == 'T') {
      if (dir == 0) xx.push_back(cnt);
      else if (dir == 1) yy.push_back(cnt);
      cnt = 0;
      dir ^= 1;
    }
  }

  if (dir == 0 && cnt > 0) xx.push_back(cnt);
  else if (dir == 1 && cnt > 0) yy.push_back(cnt);
  if (xx.empty()) xx.push_back(0);

  vector<vector<bool>> dpx(xx.size(), vector<bool>(20000, false));
  dpx[0][10000 + xx[0]] = true;
  if (xx.size() > 1) {
    for (int i = 1; i < xx.size(); i++) {
      for (int j = 0; j < dpx[i-1].size(); j++) {
        if (dpx[i-1][j]) {
          dpx[i][j + xx[i]] = true;
          dpx[i][j - xx[i]] = true;
        }
      }
    }
  }

  vector<vector<bool>> dpy(yy.size(), vector<bool>(20000, false));
  dpy[0][10000] = true;
  for (int i = 1; i < yy.size(); i++) {
    for (int j = 0; j < dpy[i-1].size(); j++) {
      if (dpy[i-1][j]) {
        dpy[i][j + yy[i]] = true;
        dpy[i][j - yy[i]] = true;
      }
    }
  }

  if (dpx[xx.size()-1][10000 + x] && dpy[yy.size()-1][10000+y]) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 20096
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
    int N; cin >> N;
//    int N; cin >> N;
    vector<string> vsN(N); REP(i, N) cin >> vsN.at(i);

    int M;cin >> M;
    vector<string> vsM(M); REP(i, M) cin >> vsM.at(i);


    int ans = 0;
    REP(i, N) {
        int score = 0;
        REP(j, N){
            if(vsN.at(i) == vsN.at(j)) score++;

        }

        REP(k, M){
            if(vsN.at(i) == vsM.at(k)) score--;
        }
        
        ans = max(score, ans);
    }
//    DEBUG_VEC(vsN);
//    DEBUG_VEC(vsM);

    cout << ans;

//    vector<string> vs(N);
//    REP(i, N) cin >> vs.at(i);
//    string O, E; cin >> O >> E;


    return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    REP(i, n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b;
  double cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合
  double sum;

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  double kruskal() {
    // コストが小さい順にソート
    sort(es.rbegin(), es.rend());

    UnionFind uf(n);
    double min_cost = 0;

    REP(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int n, m;
  cin >> n >> m;
  g.n = n;
  vi x(n), y(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
  }
  REP(i, m) {
    Edge e;
    cin >> e.a >> e.b;
    e.a--;
    e.b--;
    e.cost = hypot(x[e.a] - x[e.b], y[e.a] - y[e.b]);
    g.sum += e.cost;
    g.es.push_back(e);
  }
  return g;
}

int main(){
  Graph g = input_graph();
  printf("%.3lf\n", g.sum - g.kruskal());
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define LINE_BUF_SIZE  1024

int main(void) {
  
  int i;
  int N,M;
  int sum = 0;
  int A[10000];

  scanf("%d %d",&N,&M);
  for(i = 0; i < M; i++){
      if(i == M){
          scanf("%d",&A[i]);
      }
      scanf("%d ",&A[i]);
      sum += A[i];
  }
  
  if(sum <= N){
      printf("%d",N - sum);
  }else{
      printf("-1");
  }

  return 0;
}

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

template<typename T, int MAX_N>
struct segment_tree_sum {
    T arr[MAX_N << 1]; int N;

    segment_tree_sum(int n) {
        N = 1;
        while (N < n) N *= 2;

        for (int i = 0; i < 2*N-1; ++i) {
            arr[i] = (T)0;
        }
    }

    void add(int i, T v) {
        int j = i + N-1;
        arr[j] += v;
        while (j > 0) {
            j = (j-1) / 2;
            arr[j] += v;
        }
    }

    T query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return arr[k];

        int m = (l+r)/2;
        return query(a, b, 2*k+1, l, m) + query(a, b, 2*k+2, m, r);
    }
};

int N, Q;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> Q;
    segment_tree_sum<int, 201010> segt(N+1);
    for (int j = 0; j < Q; ++j) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            segt.add(x, y);
        } else {
            cout << segt.query(x, y+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
string s, t;
long long n, c, a[100], sum;
int main()
{
	cin >> s >> t;
	if (s[0] != t[0]) sum ++;
	if (s[1] != t[1]) sum ++;
	if (s[2] != t[2]) sum ++;
	cout << 3-sum;		
	
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m,a,b,i;
	
	for( ; scanf("%d%d",&n,&m),n|m ; printf("%d\n",a) ){
		char f[510][510]={0},g[510]={0};
		for(i=m;i--;f[a][b]=f[b][a]=1)
			scanf("%d%d",&a,&b);
		for(i=2;i<=n;i++)
			if(f[1][i])
				for(g[i]=b=1;b<=n;b++)
					if( f[i][b] )
						g[b]=1;
		for(a=0;--i>1;)
			g[i]?a++:0;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int i,j;
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if((i+j)%2==0)System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.println();
            }
         System.out.println();
        }
    }
}



Measured memory_bytes: 57724
n=int(input())
ap=[int(x) for x in input().split()]
L={}
R={}
for i,a in enumerate(ap):
  if i+a in L:
    L[i+a]+=1
  else:
    L[i+a]=1
  if i-a in R:
    R[i-a]+=1
  else:
    R[i-a]=1
ans=0
for i in range(n):
  if i in L and i in R:
    ans += L[i]*R[i]
print(ans)

Measured memory_bytes: 56764
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
deque<int> d1;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(i==1){
            d1.push_front(x);
        }
        else if(i%2==0){
            d1.push_front(x);
        }else{
            d1.push_back(x);
        }
    }
    if(!(n%2)){
        for(int i=0;i<d1.size();i++){
            cout<<d1[i]<<" ";
        }
    }else{
        for(int i=d1.size()-1;i>=0;i--){
            cout<<d1[i]<<" ";
        }
    }
}


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

int ara[2004][2009];
#define pb push_back
vector<string>v;
bool vis[2009][2009];
int h,w;
int call(int i,int j,int val)
{
    if(j==w)return val;
    if(v[i][j]=='#')return val;
    vis[i][j]=1;
    ara[i][j]+=call(i,j+1,val+1);
    return ara[i][j];
}
int call2(int i,int j,int val)
{
//    cout<<i<<" "<<j<<" "<<val<<endl;
    if(i==h)return val;
    if(v[i][j]=='#')return val;
    vis[i][j]=1;
    int tt=call2(i+1,j,val+1);
    ara[i][j]+=tt;
    return tt;
}

int main()
{
    string s;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        cin>>s;
        v.pb(s);
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(v[i][j]=='.'&&vis[i][j]==0)
            {
                call(i,j,0);
            }
        }
    }
    memset(vis,0,sizeof vis);
    for(int j=0;j<w;j++)
    {
        for(int i=0;i<h;i++)
        {
            if(v[i][j]=='.'&&vis[i][j]==0)
            {
                call2(i,j,0);
            }
        }
    }
    int mx=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            mx=max(mx,ara[i][j]);
        }
    }
    cout<<mx-1<<endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;

int solve(int a , int k){
	vector<int> v;
	v.PB(0);
	for(int i = 1 ; i*k <= a ; ++i){
		vector<int> u;
		u.PB(i);
		int z = k%i;
		repp(j,0,i){
			u.PB(v[(z+j)%i]);
		}
		swap(v,u);
	}
	int y = v.size();
	return v[(a%k)%y];
}

int calc(int a , int k){
	if(k>1000000) return solve(a,k);
	if(a<k) return 0;
	if(a%k==0) return a/k;
	return calc(a-a/k-1,k);
}

int main(){
	cin >> N;
	int g = 0;
	repp(i,0,N){
		int A,K;
		cin >> A >> K;
		g ^= calc(A,K);
	}
	cout << (g!=0?"Takahashi":"Aoki") << endl;
	return 0;
}


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

bool has_key(map<int, int> &m, int n){
    return m.find(n) != m.end();
}

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

    int p[100000];
    string S[100000];
    for (int i=0; i<M; i++) {
    	cin >> p[i] >> S[i];
    }

    map<int, int> AC;
    map<int, int> WA;
    int n_WA = 0;
    int n_AC = 0;

    for (int i=0; i<M; i++) {
    	if (has_key(AC, p[i])) {
			continue;
		}

    	if (S[i] == "WA") {
    		if (has_key(WA, p[i])) {
    			WA[p[i]]++;
    		} else {
    			WA[p[i]] = 1;
    		}
    	} else {
    		AC[p[i]] = 1;
    		n_AC++;
    	}
    }

    for (auto iter = AC.begin(); iter != AC.end(); iter++) {
    	if (has_key(WA, iter->first)) {
    		n_WA += WA[iter->first];
    	}
    }

    cout << n_AC << ' ' << n_WA << endl;

    return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    string al = "abcdefghijklmnopqrstuvwxyz";
    for(auto c: al){
        if(s.find(c) == string::npos){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
s = input()

id_a = len(s)
id_z = 0
for i in range(len(s)):
  if s[i] == 'A':
    id_a = min(id_a, i)
  if s[i] == 'Z':
    id_z = max(id_z, i)
    
print(id_z - id_a + 1)


Measured memory_bytes: 3512
#include<iostream>
#include<limits.h>
using namespace std;
const int MAX = 300000;
const int STN = INT_MAX;
typedef long long llong;

int L[MAX/2+2], R[MAX/2+2];

llong merge(int *A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0 ; i< n1; i++) L[i] = A[left+i];
	for(int i = 0; i < n2; i++) R[i] = A[mid +i];
	L[n1] = R[n2] = STN;
	int i,j;
	llong cnt = 0;
	i = j = 0;
	for(int  k = left ; k < right; k++)
	{
		if(L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;	
}

llong mergeSort(int *A, int left, int right)
{
	if(left+1<right)
	{
		int mid = (right+left)/2;
		llong v1 = mergeSort(A,left,mid);
		llong v2 = mergeSort(A,mid,right);
		llong v3 = merge(A,left, mid, right);
		return v1+v2+v3;
	}
	else return 0;
}

int main()
{
	int n;
	int A[MAX];
	cin >> n;
	for(int i = 0 ; i< n; i++)
 		cin >>A[i];
 
 	llong ans = mergeSort(A,0,n);
 	cout << ans<<endl;
}

Measured memory_bytes: 4652
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int i, j, n, k;
	char in[257], d[257];
	fscanf(stdin, "%d", &n), getchar();
	while (n--) {
		fscanf(stdin, "%[^\n]s", in), getchar();
		for (i = 1; i <= 26; i+=2) {
			for (j = 0; j <= 26; j++) {
				for (k = 0, strcpy(d, in); in[k]; k++)
					if ('a' <= d[k] && d[k] <= 'z')
						d[k] = ((in[k] - 'a')*i + j) % 26 + 'a';
				if (strstr(d, "this") || strstr(d, "that")) goto end;
			}
		}
	end: P(s,d);
	}
	return 0;
}

Measured memory_bytes: 620
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    println!(
        "{}",
        (0..n)
            .map(|_| read::<u32>().trailing_zeros())
            .min()
            .unwrap()
    );
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vvll dp(n, vll(2, -1));
    dp[n-1][0] = a[n-1];
    dp[n-1][1] = -a[n-1];
    IREP(i, n-1, 1){
        dp[i][0] = max(a[i]+dp[i+1][0], -a[i]+dp[i+1][1]);
        dp[i][1] = max(-a[i]+dp[i+1][0], a[i]+dp[i+1][1]);
    }
    dp[0][0] = a[0] + dp[1][0];
    dp[0][1] = -a[0] + dp[1][1];
    cout << max(dp[0][0], dp[0][1]) << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << en;
		return;
	}
	ll ans = (w / 2 + w % 2) * (h / 2 + h % 2);
	ans += (h / 2) * (w / 2);
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int powint(int a, int x){
	int res = 1;
	REP(i,x){
		res = res *a; 
	}
	return res;
}

using namespace std;

int main(){
	string S;
	cin>>S;
	S[3]='8';
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,q;
int A[12],a[55],b[55],c[55],d[55];
ll ans; 
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	for(int i=1;i<=n;i++)	A[i]=1;
	while(!A[0])
	{
		ll res=0;
		for(int i=1;i<=q;i++)
		{
			if(A[b[i]]-A[a[i]]==c[i])	res+=d[i];
		}
		ans=max(ans,res);
		for(int i=n;i>=0;i--)
		{
			if(A[i]<m)
			{
				A[i]++;
				for(int j=i+1;j<=n;j++)	A[j]=A[i];
				break;
			}
		}
		
	}
	cout<<ans;
return 0;
}


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

using namespace std;
const int maxn  = 1e5 + 5;
int a[maxn], b[maxn],c[maxn];
long long  n;

int main()
{
    ios::sync_with_stdio(false);
    cin >>n;
    for(int i = 0; i <n ; i++) cin >>a[i];
    for(int i =0 ; i<n; i++) cin >>b[i];
    for(int i = 0; i< n; i++) cin >> c[i];
    sort(a,a+n);
    sort(b,b +n);
    sort(c,c+n);
    long long sum = 0;
    for(int i =0 ; i <n; i++)
    {
        long long  ans = lower_bound(a, a+n,b[i]) - a;
        long long ant = upper_bound(c,c+n,b[i]) - c;
        sum += ans *(n-ant);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String[] input = sc.next().split("");
		int a = Integer.valueOf(input[0]);
		int b = Integer.valueOf(input[1]);
		int c = Integer.valueOf(input[2]);
		int d = Integer.valueOf(input[3]);
		int answer = 0;
		for(int i = 0; i < 2; i++) {
			if(i == 0) {
				answer = a + b;
			}else {
				answer = a - b;
			}
			int tmpanswer1 = answer;
			for(int j = 0; j < 2; j++) {
				answer = tmpanswer1;
				if(j == 0) {
					answer += c;
				}else {
					answer -= c;
				}
				int tmpAnswer2 = answer;
				for(int k = 0; k < 2; k++) {
					answer = tmpAnswer2;
					if(k == 0) {
						answer += d;
					}else {
						answer -= d;
					}
					if(answer == 7) {
						System.out.println(a + convert(i) + b + convert(j) + c + convert(k) + d + "=7");
						return;
					}
				}
			}
		}
	}

	private static String convert(int i) {
		if(i == 0) {
			return "+";
		}else {
			return "-";
		}
	}
}

Measured memory_bytes: 23636
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
count = 0
suma = sum(a_list)

for i in range(n):
  if a_list[i] >= (suma / (4*m)):
    count += 1
  
if count >= m:
  print("Yes")
else:
  print("No")

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

  int N = S.size();
  int64_t result = 0;
  for (int i=0; i<(1<<(N-1)); ++i) {
    vector<int> idx;
    for (int j=0; j<N-1; ++j) {
      if (i & (1 << j)) {
	idx.emplace_back(j);
      }
    }

    int st = 0;
    for (int j=0; j<idx.size(); ++j) {
      int rng = idx[j] - st + 1;
      result += stoll(S.substr(st, rng));
      st += rng;
    }
    result += stoll(S.substr(st, N - st + 1));
  }

  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] a = new long[5];
        long min = Long.MAX_VALUE;
        for (int i = 0 ; i < 5 ; i++) {
                a[i] = sc.nextLong();
                min = Math.min(min, a[i]);

        }

        long m = 0;
        if (n % min == 0) {
            m = n / min;
        } else {
            m = n / min + 1;
        }

        long ans = m + 5;




        System.out.println(ans - 1);
    }

}

Measured memory_bytes: 23892
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,x,a[500010],cnt;
int main(){
	cin>>n>>x;
	FOR(i,1,n) getint(a[i]);
	sort(a+1,a+n+1);
	FOR(i,1,n-1) if (x>=a[i]){
		x-=a[i];
		++cnt;
	}
	if (x==a[n]) ++cnt;
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int ms = 3e3+9;
long long int dp[ms][ms][2];
long long int arr[ms], n;

long long int solve(int l, int r, int player){
  if(l == r){
    if(player)
      return -arr[l];
    return arr[l];
  }

  long long int &ans = dp[l][r][player];
  if(~ans)
    return ans;

  if(player){
    ans = min( -arr[l] + solve(l+1, r, 0), -arr[r] + solve(l, r-1, 0));
  } else {
    ans = max(arr[l] + solve(l+1, r, 1), arr[r] + solve(l, r-1, 1));
  }

  return ans;
}



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

  int l = 0, r = n-1;

  memset(dp, -1, sizeof dp);
  cout<<solve(l, r, 0)<<endl;
}

Measured memory_bytes: 141952
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        if(a < b){
            if(b < c){
                System.out.println(a+" "+b+" "+c);
            }else{
                if(a < c){
                    System.out.println(a+" "+c+" "+b);
                }else{
                    System.out.println(c+" "+a+" "+b);
                }
            }
        }else{
            if(a < c){
                System.out.println(b+" "+a+" "+c);
            }else{
                if(b < c){
                    System.out.println(b+" "+c+" "+a);
                }else{
                    System.out.println(c+" "+b+" "+a);
                }
            }
        }
    }
}


Measured memory_bytes: 26244
#include<stdio.h>

int L = 0;
int R = 0;
int ans = 2018;
int x = 0;

int main(void){
  if(scanf("%d%d",&L,&R) == 1);
  if((R-L) >= 2019){
    printf("0\n");
    return 0;
  }
  for(int i = L; i < R; i++){
    for(int j = i + 1; j <= R; j++){
      x = (i%2019)*(j%2019)%2019;
      if(x < ans){
        if(x == 0){
          printf("0\n");
          return 0;
        }
        ans = x;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define max(x,y) (x>y?x:y)
int main()
{
    int alti=0,maxn=0,n;
    char ch;
    cin>>n;
	for(int i=1;i<=n;i++)
    {
    	cin>>ch;
    	if(ch=='I')alti++;
    	else alti--;
    	maxn=max(maxn,alti);
	}
	cout<<maxn;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
#include<bitset>
using namespace std;

int main() {
	int n; cin >> n;
	int a = 0, w = 0, t = 0, r = 0;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if (s == "AC")a++;
		else if (s == "WA")w++;
		else if (s == "TLE")t++;
		else if (s == "RE")r++;
	}
	cout << "AC x " << a << endl << "WA x " << w << endl << "TLE x " << t << endl;
	cout << "RE x " << r << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    vector<double> x(N);
    vector<string> u(N);

    double ans = 0;

    REP(i,N)
    {
        cin >> x[i];
        cin >> u[i];
        if(u[i] == "JPY")
        {
            ans += x[i];
        }
        else
        {
            ans += x[i] * 380000.0;
        }
    }
    cout << ans << endl;

}


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

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		int W, H;
		cin >> W >> H;
		vector< vector<int> > dp(H + 1, vector<int>(W + 1));
		for(int i = 0; i < N; ++i)
		{
			int x, y;
			cin >> x >> y;
			dp[y][x] = 1;
		}
		for(int i = 1; i <= H; ++i)
		{
			for(int j = 1; j <= W; ++j)
			{
				dp[i][j] += dp[i][j - 1];
			}
		}
		for(int i = 1; i <= W; ++i)
		{
			for(int j = 1; j <= H; ++j)
			{
				dp[j][i] += dp[j - 1][i];
			}
		}

		int S, T;
		cin >> S >> T;
		int max_val = 0;
		for(int i = T; i <= H; ++i)
		{
			for(int j = S; j <= W; ++j)
			{
				max_val = max(max_val, dp[i][j] - dp[i - T][j] - dp[i][j - S] + dp[i - T][j - S]);
			}
		}
		cout << max_val << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1260
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    char s1[200],s2[200];
    int i,ii,j;
    scanf("%s",s1);
    scanf("%s",s2);
    for(i=0;i<strlen(s1);i++)
    {
        ii = i;
        for(j=0;j<strlen(s2);j++,ii++)
        {
            if(ii>=strlen(s1))
                ii-=strlen(s1);
            if(s1[ii]!=s2[j])
                break;
        }
        if(j==strlen(s2))
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}




Measured memory_bytes: 2116
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if (A + B >= C) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <cstdio>

using namespace std;

#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)

int J[1001][1001];
int O[1001][1001];
int I[1001][1001];

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

	rep1(i, N) rep1(j, M) {
		char c; scanf("\n%c", &c);
		if (c == 'J') J[i][j] = 1;
		if (c == 'O') O[i][j] = 1;
		if (c == 'I') I[i][j] = 1;
	}

	rep1(i, N) rep1(j, M) {
		J[i][j] += J[i][j - 1];
		O[i][j] += O[i][j - 1];
		I[i][j] += I[i][j - 1];
	}

	rep1(i, M) rep1(j, N) {
		J[j][i] += J[j - 1][i];
		O[j][i] += O[j - 1][i];
		I[j][i] += I[j - 1][i];
	}

	rep(ii, K) {
		int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
		int j = J[c][d] - J[a - 1][d] - J[c][b - 1] + J[a - 1][b - 1];
		int o = O[c][d] - O[a - 1][d] - O[c][b - 1] + O[a - 1][b - 1];
		int i = I[c][d] - I[a - 1][d] - I[c][b - 1] + I[a - 1][b - 1];
		printf("%d %d %d\n", j, o, i);
	}
}

Measured memory_bytes: 12724
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#define T long long

int main(){
	T a,b,n;
	std::cin >> a>>b>>n;
	std::cout << (a*std::min(b-1,n)/b)<<std::endl;
}


Measured memory_bytes: 3584
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC167
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var s = Next();
            var t = Next();

            Console.WriteLine(t.Substring(0, s.Length) == s ? "Yes" : "No");
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 25804
N = int(input())
MOD = 10**9+7

def for_factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val = val%MOD
    return val

def for_ten(n):
  val = 1
  for i in range(n):
    val *= 10
    val = val%MOD
  return val

def for_nine(n):
  val = 1
  for i in range(n):
    val *= 9
    val = val%MOD
  return val

def for_eight(n):
  val = 1
  for i in range(n):
    val *= 8
    val = val%MOD
  return val

answer = (-2*for_nine(N)+for_eight(N)+for_ten(N))%MOD
print(answer)

Measured memory_bytes: 63920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		int direction[][] = new int[][] {{0,-1},{-1,0},{0,1},{1,0}};
		char[][] s = new char[h][w];
		for(int i=0; i<h; i++){
			String line = sc.next();
			s[i] = line.toCharArray();
		}
		boolean result = true;
		for (int i=0; i<h; i++){
			for (int j=0; j<w; j++){
				char masu = s[i][j];
				boolean tonariFlg=false;
				if (masu == '#'){
					tonariFlg = false;
					for (int k=0; k<direction.length; k++){
						int x = i + direction[k][0];
						int y = j + direction[k][1];
						if ((x >= 0 && y >= 0) && (x < h && y < w)){
							char tonari = s[x][y];
							if (tonari == '#'){
								tonariFlg = true;
								break;
							}
						}
					}
					if (!tonariFlg){
						result = false;
						break;
					}
				}
			}
			if (result == false){
				break;
			}
		}
		if (result){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split(" ")))


flag = True

for a in A:
    if a % 2 == 0:
        if not (a % 3 == 0 or a % 5 == 0):
            flag = False


if flag:
    print("APPROVED")
else:
    print("DENIED")

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr); 
	ll animals,legs;
	cin>>animals>>legs;
	ll crane = 2,turtle = 4;
	FORE(i,0,animals)
	{
		ll cranel = i*crane;
		ll turtlel = (animals-i)*turtle;
		if(cranel+turtlel == legs)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628