akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define pq priority_queue
#define um unordered_map
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define what_is(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    int n, l;
    cin >> n >> l;
    int a;
    int s = 0;
    int m = 10000000, ans;
    for (int i = 1; i <= n; i++) {
        a = l + i - 1;
        s += a;
        if (abs(a) < m || a == m) {
            ans = a;
            m = abs(a);
        }
    }
    cout << s - ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i < (int)(n); i++)
#define np next_permutation
typedef long long ll;


int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a, b;
  cin >> a >> b;

  if(a >= 6 && a <= 12) cout << b / 2 << endl;
  else if(a >= 13) cout << b << endl;
  else cout << 0 << endl;
}

/*





















*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

VE g[100001];
int color[100001]={};

void dfs(int s, int c){
    color[s]=c;
    FOR(i,0,g[s].size()){
        if(color[g[s][i]]!=c){
            dfs(g[s][i],c);
        }
    }
}

int main(){
    int n,m; cin>>n>>m;
    int p[100001]={};
    FOR(i,0,n){
        cin>>p[i];
        p[i]--;
    }
    FOR(i,0,m){
        int x,y; cin>>x>>y;
        g[x-1].PB(y-1);
        g[y-1].PB(x-1);
    }
    int c=1;
    FOR(i,0,n){
        if(color[i]==0){
            dfs(i,c);
            c++;
        }
    }
    int ans=0;
    FOR(i,0,n){
        if(color[i]==color[p[i]]) ans++;
    }
    co(ans);
}


Measured memory_bytes: 9472
n = int(input())

march = ("M","A","R","C","H")
prefix = []
d = {}
for _ in range(n):
  pre = input()[0]
  if pre in march:
    if pre not in prefix:
      prefix.append(pre)
      d[pre] = 1
    else:
      d[pre] += 1
      
t = len(prefix)
if t < 3:
  print(0)
  exit()

ans = 0
for i in range(t-2):
  for j in range(i+1, t-1):
    for k in range(j+1,t):
      ans += d[prefix[i]]*d[prefix[j]]*d[prefix[k]]
print(ans)

Measured memory_bytes: 9240
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <string.h>
#include <set>
#include <unordered_set>
#define mod 1000000007
#define maxn 100050
using namespace std;

int grid[110][110];




void move_cursor(int& i, int& j, int dir){
    if(dir == 1){
        i++;
    }else if(dir == 2){
        j++;
    }else if(dir == 3){
        i--;
    }else{
        j--;
    }
}

void change_dir(int& i, int& j, int& dir, int& r, int& c){
    if(i == r){
        i--;
        j++;
        dir = 2;
    }else if(j == c){
        j--;
        i--;
        dir = 3;
    }else{
        switch (dir) {
            case 1:
                i--;
                j++;
                dir = 2;
                break;
            case 2:
                j--;
                i--;
                dir = 3;
                break;
            case 3:
                i++;
                j--;
                dir = 4;
                break;
            default:
                j++;
                i++;
                dir = 1;
                break;
        }
    }
}

void paint(int& i_cursor, int& j_cursor, int& dir, int color, int r, int c, int& cnt){
    if(cnt == 0){
        return;
    }
    if(i_cursor == r || j_cursor == c || grid[i_cursor][j_cursor] != -1){
        change_dir(i_cursor, j_cursor, dir, r, c);
    }
    grid[i_cursor][j_cursor] = color;
    move_cursor(i_cursor, j_cursor, dir);
    paint(i_cursor, j_cursor, dir, color, r, c, --cnt);
}
int main(){
    int r, c, n;
    scanf("%d %d %d", &r, &c, &n);
    memset(grid, -1, sizeof(grid));
    
    vector<int> a(n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    int x_cursor = 0, y_cursor = 0;
    int dir = 1;
    for(int i=0; i<n; i++){
        if(a[i]){
            paint(x_cursor, y_cursor, dir, i+1, r, c, a[i]);
        }
    }
    for(int i=0; i<r; i++){
        printf("%d", grid[i][0]);
        for(int j=1; j<c; j++){
            printf(" %d", grid[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>

typedef long long ll;
const ll INF = 1e18 + 1;

template<typename InputIterator> void printVec(InputIterator begin, InputIterator end)
{
  std::cout << "printVec ";
  for (InputIterator it = begin; it != end; it++) { std::cout << *it << " "; }
  std::cout << std::endl;
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N, M, R;
  std::cin >> N >> M >> R;

  std::vector< std::vector< ll > > distance(N, std::vector< ll >(N, INF));
  std::vector< ll > vr(R);
  for (ll i = 0; i < R; i++) {
    std::cin >> vr[i];
    vr[i]--;
  }
  for (ll i = 0; i < M; i++) {
    ll a, b, c;
    std::cin >> a >> b >> c;
    a--;
    b--;
    distance[a][b] = c;
    distance[b][a] = c;
  }
  for (ll i = 0; i < N; i++) {
    distance[i][i] = 0;
  }

  for (ll k = 0; k < N; k++) {
    for (ll i = 0; i < N; i++) {
      for (ll j = 0; j < N; j++) {
	distance[i][j] = std::min(distance[i][j], distance[i][k] + distance[k][j]);
      }
    }
  }

  ll ans = INF;
  std::sort(vr.begin(), vr.end());
  do {
    ll all_distance = 0;
    for (ll i = 0; i < (ll)vr.size() - 1; i++) {
      all_distance += distance[vr[i]][vr[i+1]];
    }
    ans = std::min(ans, all_distance);
  } while (std::next_permutation(vr.begin(), vr.end()));

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n,k; cin >> n >> k;
  vector<double> exp(n);
  double tmp; REP(i,n){ cin >> tmp; exp[i] = (1 + tmp) / 2;}
  vector<double> cumu(n+1,0);
  REP(i,n){
    cumu[i+1] = cumu[i] + exp[i];
  }
  double ans=0,sum=0;
  REP(i,n-k+1){
    sum = cumu[k+i] - cumu[i];
    ans = max(sum,ans);
  }
  printf("%.16lf",ans);
}

Measured memory_bytes: 6468
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        
        if (str.charAt(0) == str.charAt(1) && str.charAt(2) == str.charAt(3) && str.charAt(1) == str.charAt(2)) {
            System.out.println("No");
        } else if (str.charAt(0) == str.charAt(1) && str.charAt(2) == str.charAt(3)) {
                System.out.println("Yes");
        } else if (str.charAt(0) == str.charAt(2) && str.charAt(1) == str.charAt(3)) {
                System.out.println("Yes");
        } else if (str.charAt(0) == str.charAt(3) && str.charAt(1) == str.charAt(2)) {
                System.out.println("Yes");
        } else {
                System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n,m;
  cin>>n>>m;
  VEC<int>cnt(m,0);
  REP(i,0,n){
    int k;
    cin>>k;
    REP(j,0,k){
      int c;
      cin>>c;
      --c;
      cnt[c]++;
    }
  }
  DUMP(cnt);
  int ans = 0;
  REP(i,0,m){
    if(cnt[i]==n)++ans;
  }
  cout<<ans;

  return 0;
}


Measured memory_bytes: 256
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        Date a = sdf.parse("2019/04/30");
        Date d = sdf.parse(s);

        if(a.compareTo(d) >= 0)System.out.println("Heisei");
        else System.out.println("TBD");
        sc.close();
    }

}


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

////////////////////
// Ford-Fulkerson //
////////////////////

class MaxFlow {
private:
	using vi64 = std::vector<int64_t>;
	using Matrix = std::vector<vi64>;
	std::vector<bool> visited_;

	Matrix graph_;

	int64_t findPath(const int source, const int sink, const int node_i, const int64_t flow)
	{
		if (node_i == sink) return flow;
		visited_[node_i] = true;
		for (int next_i{}; next_i < (int)graph_.size(); next_i++)
		{
			if (!graph_[node_i][next_i] || visited_[next_i]) continue;
			const int64_t additional_flow{findPath(source, sink, next_i, std::min(flow, graph_[node_i][next_i]))};
			if (!additional_flow) continue;

			graph_[node_i][next_i] -= additional_flow;
			graph_[next_i][node_i] += additional_flow;
			return additional_flow;
		}
		return 0;
	}
public:
	MaxFlow(const int node_num)
		: graph_(node_num, vi64(node_num)), visited_(node_num){}
	void add_edge(const int from, const int to, const int64_t flow)
	{
		graph_[from][to] += flow;
	}
	int64_t operator()(const int source, const int sink)
	{
		int64_t flow_sum{};
		while (true)
		{
			std::fill(visited_.begin(),visited_.end(), false);
			int64_t additional_flow{findPath(source, sink, source, LLONG_MAX)};
			if (!additional_flow) break;
			flow_sum += additional_flow;
		}
		return flow_sum;
	}
};

int main()
{
	int X, Y, E;
	scanf("%d%d%d", &X, &Y, &E);
	MaxFlow bin_match(X + Y + 2);
	for (int x_i{1}; x_i <= X; x_i++)
		bin_match.add_edge(0, x_i, 1);
	for (int y_i{X + 1}; y_i < X + Y + 2; y_i++)
		bin_match.add_edge(y_i, X + Y + 1, 1);
	
	for (int e_i{}; e_i < E; e_i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		bin_match.add_edge(1 + x, X + 1 + y, 1);
	}
	printf("%lld\n", bin_match(0, X + Y + 1));
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,K;
    string S;
    cin >> N;
    cin >> S;
    cin >> K;
    K--;
    for (int i = 0; i < N; i++) {
        if(S[i] != S[K]){
            cout << '*';
        } else {
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3540
use strict;
use warnings;

my $in = <>;
chomp $in;
my @odd = split(//, $in);

$in = <>;
chomp $in;
my @even = split(//, $in);

while (@odd || @even){
	if (@odd){
		print shift @odd;
	}
	if (@even){
		print shift @even;
	}
}
print "\n";

exit;


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, M, Q;
ll a[55], b[55], c[55], d[55];

ll dfs(vector<ll> v, ll n) {
  ll i;
  
  if(n==N) {
    ll t=0;
    for(i=0; i<Q; i++) if(v[b[i]]-v[a[i]]==c[i]) t+=d[i];
    return t;
  }
  
  ll res=0;
  
  for(i=(n==0) ? 1:v[n-1]; i<=M; i++) {
    vector<ll> u(n);
    copy(v.begin(), v.end(), u.begin());
    u.push_back(i);
    chmax(res, dfs(u, n+1));
  }
  
  return res;
}

int main(void) {
  ll i, j, k;
  
  cin >> N >> M >> Q;
  for(i=0; i<Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  
  vector<ll> v;
  pt(dfs(v, 0));
}
 
 


Measured memory_bytes: 3584
#include <stdio.h>

int main()
{
    int i, j, k, max;
    int n[5];
    
    scanf("%d %d %d %d %d", n, n+1, n+2, n+3, n+4);
    
    for (i = 0; i < 5; i++) {
        k = i;
        max = n[i];
        for (j = i; j < 5; j++) {
            if (n[j] > max) {
                k = j;
                max = n[j];
            }
        }
        n[k] = n[i];
        n[i] = max;
    }
    
    printf("%d %d %d %d %d\n", n[0], n[1], n[2], n[3], n[4]);
    
    return 0;
}
                    


Measured memory_bytes: 2036
import sys


S = input()
length_S = len(S)

cursor_head = 0
cursor_tail = -1

ret = 0

while length_S + cursor_tail > cursor_head:
  if S[cursor_head] == S[cursor_tail]:
    cursor_head += 1
    cursor_tail -= 1
  else:
    if S[cursor_head] == 'x':
      cursor_head += 1
      ret += 1
    elif S[cursor_tail] == 'x':
      cursor_tail -= 1
      ret += 1
    else:
      print(-1)
      sys.exit()
    
print(ret)


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

A.sort()

if(N%2==0):
    for i in range(N//2):
        if((A[i*2]!=(1+i*2))|(A[2*i+1]!=(1+i*2))):
            print(0)
            exit()
    print((2**(N//2)) % int(1e9+7))

else:
    if(A[0]!=0):
            print(0)
            exit()
    for i in range(N//2):
        if((A[i*2+1]!=((i+1)*2))|(A[i*2+2]!=((i+1)*2))):
            print(0)
            exit()
    print((2**(N//2)) % int(1e9+7))


Measured memory_bytes: 13880
#include<stdio.h>
int main(){
    char str[5];
    scanf("%s", str);
    bool isGood=true;
    for(int i=1; i<4; i++){
        if(str[i]==str[i-1]){
            isGood=false;
        }
    }
    printf("%s\n", (isGood ? "Good" : "Bad"));
    return 0;
}


Measured memory_bytes: 128
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 12, INF = 0x3f3f3f3f;

int dp[1 << N];

int main() {
	int n, m; cin >> n >> m;
	fill(dp, dp + (1 << n), INF);
	dp[0] = 0;
	while (m--) {
		int a, b; cin >> a >> b;
		int x = 0;
		while (b--) {
			int c; cin >> c, c--;
			x |= 1 << c;
		}
		for (int y = 0; y < 1 << n; y++)
			if (dp[y] != INF)
				dp[y | x] = min(dp[y | x], dp[y] + a);
	}
	int ans = dp[(1 << n) - 1];
	cout << (ans != INF ? ans : -1) << '\n';
	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        char[] S = sc.next().toCharArray();
        long blackCount = 0;
        long count = 0;
        for (int i = 0; i < S.length; i++) {
            if (S[i] == 'B') {
                blackCount++;
            } else {
                count += blackCount;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26544
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <unordered_map>
     
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    using namespace std;
    typedef long long ll;
     
    ll combination(int n) {
        
        return n * (n-1) / 2;
    }
     
     
     
    int main(int argc, const char * argv[]) {
        
        cin.tie(0);
        ios::sync_with_stdio(false);
        
        int n;
        cin >> n;
        
        unordered_map<string, int> mp(n);
        string s;
        rep(i, n)
        {
            cin >> s;
            sort(s.begin(), s.end());
            mp[s]++;
        }
        
        
        
        ll cnt = 0;
        for (auto& p : mp)
        {
            int num_duplicate = p.second;
            cnt += (ll)num_duplicate * (num_duplicate - 1) / 2;
        }
        
        cout << cnt << endl;
        
        return 0;
    }

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

int main() {
	int n, m;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		int sum=0,maxv=0;
		//bool flag = true;
		vector<int> a(n);
		for (int i = 0; i < n; i++)cin >> a[i];

		sort(a.begin(), a.end());
		for (int i = n-1; i >= 0; i--) {
			for (int j = n-2; j >= 0; j--) {
				if (i != j)  sum += a[i] + a[j];
				if (max(maxv, sum) == sum && sum <= m) {
					maxv = sum;
					sum = 0;
					//flag = false;
				} else {
					sum = 0;
				}
			}
		}
		if (maxv==0)cout << "NONE" << endl;
		else cout << maxv << endl;
	}
}


Measured memory_bytes: 3152
import sys
a, b = map(int, input().split())
s = list(input())

if len(s) == a+b+1:
    if s[a] == "-":
        s.pop(a)
        for i in s:
            if i == "-":
                print("No")
                sys.exit()
    else:
        print("No")
        sys.exit()
else:
    print("No")
    sys.exit()
print("Yes")


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
int map[300][300] ;
int h[300][300] ;
int temp[7] ;
int bz[7];
int have[7] ;
int t , f, n ;
void r( int way ){
	if ( way == 1 ) {
		int tmp = temp[1] ;
		temp[1] = temp[4] ;
		temp[4] = temp[6] ;
		temp[6] = temp[3] ;
		temp[3] = tmp;
	}
	else if ( way == 2 ){
		int tmp = temp[1] ;
		temp[1] = temp[2] ;
		temp[2] = temp[6] ;
		temp[6] = temp[5] ;
		temp[5] = tmp;
	}
	else if ( way == 3 ){
		int tmp = temp[2] ;
		temp[2] = temp[3] ;
		temp[3] = temp[5] ;
		temp[5] = temp[4] ;
		temp[4] = tmp;
	}
}
void rol( int t , int f ) {
	memcpy( temp , bz , sizeof( temp ) ) ;
	if ( t == 6 || t == 3 || t == 4 ) {
		while( temp[1] != t )
			r( 1 ) ;
	}
	else if ( t == 2 || t == 5 ) {
		while ( temp[1] != t )
			r( 2 ) ;
	}
	while ( temp[3] != f )
		r( 3 ) ;
}
int cal( int x , int y , int i ){
	if ( i == 2 ) y -- ;
	if ( i == 3 ) x ++ ;
	if ( i == 4 ) x -- ;
	if ( i == 5 ) y ++ ;
	return h[x][y] ;
}
void inc( int x , int y ){
	int way = 0 ;
	int ans = 0 ;
	for ( int i = 2 ; i <= 5 ; i ++ ){
		if ( temp[i] >= 4 && h[x][y] > cal( x , y , i ) ){
			if ( ans < temp[i] ){
				ans = temp[i] ;
				way = i ;
			}
		}
	}
	if ( way == 0 ) {
		have[map[x][y]] -- ;
		have[temp[1]] ++ ;
		map[x][y] = temp[1] ;
		h[x][y] ++ ;
		return ;
	}
	if ( way == 2 ) {
		r( 2 ) ; r(2) ; r(2);
		inc( x , y - 1 );
	}
	else if ( way == 3 ){
		r(1);
		inc( x + 1 , y ) ;
	}
	else if ( way == 4 ){
		r(1) ; r(1);r(1);
		inc( x - 1 , y ) ;
	}
	else if(  way == 5 ) {
		r(2) ;
		inc( x , y + 1 );
	}
}
int main(){
	while ( scanf("%d" , &n ) == 1 ) {
		memset(have,0,sizeof(have));
		memset(map,0,sizeof(map));
		memset(h,0,sizeof(h));
		if ( n == 0 )
			return 0  ;
		bz[1] = 1 ; bz[2] = 2 ; bz[3] = 3 ; bz[4] = 4 ; bz[5] = 5 ; bz[6] = 6 ;
		for ( int i = 1 ; i <= n ; i ++ ) {
			scanf("%d %d" , &t , &f ) ;
			rol( t , f ) ;
			inc( 150 , 150 ) ;
		}
		for ( int i = 1 ; i <= 5 ; i ++ ){
			printf("%d " , have[i]) ;
		}
		printf("%d\n" , have[6]);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

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

	int m = 0;
	m = n / 15;
	cout << n * 800 - m * 200 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,j;
string s,a;
int main()
{
  for(cin>>s;i<s.size();i++){
    if(s[i]=='B')a=a.substr(0,a.size()-1);
    else a+=s[i];
  }
  cout<<a<<endl;
}

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 n, k;
	cin >> n >> k;

	cout << (n - 1 + ((k - 1) - 1)) / (k - 1) << endl;
}
// END

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


Measured memory_bytes: 256
mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    nmax = 2 * 10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N, M, K = map(int, input().split())

    ans = 0
    for k in range(K+1):
        ans = (ans + (M * (pow(M-1, N-k-1, mod) * comb(N-1, k))%mod)%mod) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73340
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  vector<int> ans(201);
  for(int i=0;i<K;i++){
    if(A+i<=B)  ans.at(i)=A+i;
    if(B-i>A)  ans.at(200-i)=B-i;
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<201;i++){
    if(ans.at(i)!=0 && ans.at(i)!=ans.at(i-1)){
      cout << ans.at(i) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))

t = 100000000000
ans = 0
for i in range(N):
	if abs(A - (T - H[i] * 0.006)) < t:
		ans = i + 1
		t = abs(A - (T - H[i] * 0.006))

print(ans)

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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m), y(m);
    for(int i = 0; i < m; ++i) cin >> x[i] >> y[i];
    rep(m) {
        x[i]--; y[i]--;
    }


    // 箱に入ってる玉の数
    vector<int> num(n);
    // 箱に赤い球が入っているかもしれないかどうか
    map<int, bool> isRed;

    rep(n) {
        num[i] = 1;
        isRed[i] = false;
    }

    isRed[0] = true;

    rep(m) {
        if(num[x[i]] == 0) continue;

        num[x[i]]--;
        num[y[i]]++;
        // 渡す側に赤い球が含まれているなら，渡した先に赤い球が行く可能性がある．
        if(isRed[x[i]]) isRed[y[i]] = true;
        // 渡す側にから玉が尽きたら，赤い球は入っていない．
        if(num[x[i]] == 0 && isRed[x[i]]) isRed[x[i]] = false;

        // for(auto j : num) cout << j << " ";
        // cout << endl;
        // for(auto j : isRed) cout << ((j.second)?"@":"O") << " ";
        // cout << endl;
    }

    int ans = 0;
    for(auto i : isRed) {
        if(i.second) ans++;
    }

    cout << ans;
}

Measured memory_bytes: 6144
import java.io.InputStream
import java.io.PrintStream
import java.util.*

class Abc081B(
    val input: InputStream,
    val output: PrintStream
) {
    fun calc(n: Int): Int {
        var c = 0
        var n2 = n
        while (true) {
            if (n2 % 2 == 0) {
                n2 /= 2
                c++
            } else {
                return c
            }
        }
    }

    fun proc() {
        val sc = Scanner(input)
        val n = sc.nextInt()
        val input = arrayListOf<Int>()

        // なるべく偶数にする
        // int に収まる
        // a < 1,000,000,000

        repeat(n) {
            input.add(sc.nextInt())
        }

        // 足を引っ張るのを見つける
        val c = input.map { calc(it) }.min()

        output.print(c)
    }
}

fun main(args: Array<String>) {
    Abc081B(System.`in`, System.out).proc()
}


Measured memory_bytes: 31272
#include<iostream>

using namespace std;

int main(){
    int k, n, i, sum = 1;
    cin >> n >> k;
    for (i = 0; i < n; ++ i){
        if(i == 0){
            sum *= k;
        }
        else{
            sum *= k - 1;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	int A[N], xo = 0;
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]), xo = xo ^ A[i];
	for (int i = 0; i < N; ++i) printf("%d ", xo ^ A[i]);
	return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  ll d = n % 10;
  if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9) cout << "hon" << endl;
  else if(d == 0 || d == 1 || d == 6 || d == 8) cout << "pon" << endl;
  else if(d == 3) cout << "bon" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

char C;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> C;

  printf("%c", C + 1);

  return 0;
}


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

using namespace std;

class UFDS
{
    std::vector<int> size, ps;
    int len = 1;

public:
    UFDS(int N) : size(N + 1, 1), ps(N + 1)
    {
        std::iota(ps.begin(), ps.end(), 0);
    }

    int find_set(int x)
    {
        return x == ps[x] ? x : (ps[x] = find_set(ps[x]));
    }

    bool same_set(int x, int y) { return find_set(x) == find_set(y); }

    void union_set(int x, int y)
    {
        if (same_set(x, y))
            return;

        int p = find_set(x);
        int q = find_set(y);



        if (size[p] < size[q])
            std::swap(p, q);

        ps[q] = p;
        size[p] += size[q];
        len = max(len, size[p]);
    }

    int get_len() { return len; }
};

int main()
{
    ios::sync_with_stdio(false);

    long long n, m;
    cin >> n >> m;

    UFDS ufds(n);

    while (m--)
    {
        int x, y;
        cin >> x >> y;
        ufds.union_set(x, y);
    }

    int s = ufds.get_len();

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	cin >> N;
	int L[11];
	vector<int>sum(N);
	bool can = true;
	for (int i = 0; i < N; ++i) {
		cin >> L[i];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (j != i)sum[i] += L[j];
		}
	}
	for (int i = 0; i < N; ++i) {
		if (L[i] >= sum[i])can = false;
	}
	if (can)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a + (b - a) * 2 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SSS")
	cout<<0;
	if(s=="SSR")
	cout<<1;
	if(s=="SRR")
	cout<<2;
	if(s=="SRS")
	cout<<1;
	if(s=="RSR")
	cout<<1;
	if(s=="RRS")
	cout<<2;
	if(s=="RRR")
	cout<<3;
	if(s=="RSS")
	cout<<1;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1;string s2;cin>>s1>>s2;
  int c=0;
  for(int i=0;i<s1.length();i++)
  {if(s1[i]!=s2[i]) ++c;}
  cout<<c;
  return 0;
}

Measured memory_bytes: 3836
#include <cstdio>
#include <vector>
#include <queue>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int dy[] = { -1, 1, 0, 0 };
const int dx[] = { 0, 0, 1, -1 };
struct point_t { int y, x; };
const int inf = 1e9+7;

int main() {
    // input
    int h, w, k; scanf("%d%d%d", &h, &w, &k);
    auto closed = vectors(h, w, bool());
    point_t start;
    repeat (y,h) repeat (x,w) {
        char c; scanf(" %c", &c);
        closed[y][x] = c == '#';
        if (c == 'S') {
            start.y = y;
            start.x = x;
        }
    }
    // solve
    point_t goal = { -1, -1 };
    auto is_on_field = [&](int y, int x) { return 0 <= y and y < h and 0 <= x and x < w; };
    auto is_goal = [&](int y, int x) { return y == 0 or y == h-1 or x == 0 or x == w-1; };
    auto dist = vectors(h, w, inf);
    { // // bfs
        queue<point_t> que;
        dist[start.y][start.x] = 0;
        que.push(start);
        while (not que.empty()) {
            point_t p = que.front(); que.pop();
            if (is_goal(p.y, p.x)) {
                goal = p;
                break;
            }
            if (dist[p.y][p.x] == k) continue;
            repeat (i,4) {
                point_t q = p;
                q.y += dy[i];
                q.x += dx[i];
                if (not is_on_field(q.y, q.x)) continue;
                if (closed[q.y][q.x]) continue;
                if (dist[q.y][q.x] <= dist[p.y][p.x] + 1) continue;
                dist[q.y][q.x] = dist[p.y][p.x] + 1;
                que.push(q);
            }
        }
    }
    // // bfs
    if (goal.y == -1) {
        queue<point_t> que;
        repeat (y,h) repeat (x,w) {
            if (dist[y][x] != inf) {
                dist[y][x] = k;
                que.push((point_t) { y, x });
            }
        }
        while (not que.empty()) {
            point_t p = que.front(); que.pop();
            if (is_goal(p.y, p.x)) {
                goal = p;
                break;
            }
            repeat (i,4) {
                point_t q = p;
                q.y += dy[i];
                q.x += dx[i];
                if (not is_on_field(q.y, q.x)) continue;
                if (dist[q.y][q.x] <= dist[p.y][p.x] + 1) continue;
                dist[q.y][q.x] = dist[p.y][p.x] + 1;
                que.push(q);
            }
        }
    }
    // output
    assert (goal.y != -1);
    int result = (dist[goal.y][goal.x] + k - 1) / k;
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 6040
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define EPS (1e-10)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define MAX 1000
using namespace std;

// library --- start
class Point
{
  public:
  double x,y;

  Point(double x = -1,double y = -1): x(x),y(y){}

  Point operator + (Point p ){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}//※イケメンに限る

  bool operator < (const Point& p) const{ return !equals(x,p.x)?x<p.x:y<p.y; }

};

struct Segment
{
  Point p1,p2;
  Segment(Point p1 = Point(-1,-1),Point p2 = Point(-1,-1)):p1(p1),p2(p2){}
};
typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }

double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }

int ccw(Point p0,Point p1,Point p2)
{
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS)return CLOCKWISE;
  if(dot(a,b) < -EPS)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersectSS(Line s, Line t) {
  return ccw(s.p1,s.p2,t.p1)*ccw(s.p1,s.p2,t.p2) <= 0 &&
         ccw(t.p1,t.p2,s.p1)*ccw(t.p1,t.p2,s.p2) <= 0;
}

Point crosspoint(Line l, Line m) {
  double A = cross(l.p2 - l.p1, m.p2 - m.p1);
  double B = cross(l.p2 - l.p1, l.p2 - m.p1);
  if (abs(A) < EPS && abs(B) < EPS) return m.p1; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m.p1 +   (m.p2 - m.p1) * (B / A);
}

// library --- end

struct Pox
{
  Segment s;
  double dist;
  bool o,l;
  Pox(Segment s=Segment(),double dist=inf,bool o=false,bool l=false):s(s),dist(dist),o(o),l(l){}

  bool operator < (const Pox& a)const{ return dist < a.dist; }

};

Point a,b;
int n;
Segment seg[MAX];
Pox     pox[MAX];

int compute(bool state)
{
  int cnt = 0;
  rep(i,n)//0
    {
      if(pox[i].dist == inf)break;
      if(pox[i].o)
	{//it's me
	  if(pox[i].l != state)
	    {
	      cnt++;
	      state = !state;
	    }
	}
      else
	{//mario
	  if(pox[i].l == state)
	    {
	      cnt++;
	      state = !state;
	    }
	}
    }
  return cnt;
}

int main()
{
  int T;
  while(cin >> T)
    {
      while(T--)
	{
	  cin >> a.x >> a.y >> b.x >> b.y;
	  cin >> n;
	  rep(i,n)
	    {
	      cin >> seg[i].p1.x >> seg[i].p1.y >> seg[i].p2.x >> seg[i].p2.y >> pox[i].o >> pox[i].l;
	      pox[i].s = seg[i];
	      Point p = (intersectSS(Segment(a,b),seg[i])?crosspoint(Segment(a,b),seg[i]):Point(inf,inf));
	      pox[i].dist = (intersectSS(Segment(a,b),seg[i])?sqrt(norm(a-p)):inf);
	    }	  
	  sort(pox,pox+n); 

	  cout << min(compute(false),compute(true)) << endl;
	}
    }
  return 0;
}
 

Measured memory_bytes: 1312
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}

int n, t, a,c,d=0;
double b=INF;
double deg(int xx) {
	return t - xx * 0.006;
}

signed main() {
	cin >> n >> t >> a;
	rep(i, n) {
		cin >> c;
		if (b > abs(a - deg(c))) {
			d = i + 1;
			b = abs(a - deg(c));
		}
	}
	cout << d << endl;
}




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

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void solve(){
    string s,ans="No";
    cin>>s;
    for(auto c:s){
        if(c=='7')ans="Yes";
    }
    cout<<ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
/**
 *      purpose : ABC 106 D
 *      author  : kyomukyomupurin
 *      created : 2018-11-22 01:24:09
**/

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
#define print(x) cout << (x) << '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m, Q; cin >> n >> m >> Q;
    int l[m], r[m];
    for (int i = 0; i < m; ++i) cin >> l[i] >> r[i];
    int p[Q], q[Q];
    for (int i = 0; i < Q; ++i) cin >> p[i] >> q[i];

    int square[n + 5][n + 5] = {};
    for (int i = 0; i < m; ++i){
        ++square[l[i]][r[i]];
    }
    int s[n + 5][n + 5] = {};

    for (int i = 1; i <= n; ++i){
        s[i][1] = square[i][1];
    }

    for (int i = 1; i <= n; ++i){
        for (int j = 2; j <= n; ++j){
            s[i][j] = s[i][j - 1] + square[i][j];
        }
    }

    for (int i = 0; i < Q; ++i){
        int sum = 0;
        for (int j = p[i]; j <= q[i]; ++j){
            sum += s[j][q[i]] - s[j][p[i] - 1];
        }
        print(sum);
    }

    
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}


//------------------------main function-------------------------------
//sum of 5n+2 5n+4 (1 <= n <= 19)
//

void Main(){
    ll n , q; cin >> n >> q;
    vector<char> s(n);
    vector<ll> idx;
    cin >> s[0];
    for(ll i = 1; i < n; i ++){
        cin >> s[i];
        if(s[i-1] == 'A' && s[i] == 'C'){
            idx.push_back(i);
        }
    }
    sort(idx.begin(), idx.end());
    ll left[q], right[q];
    rep(i, q) cin >> left[i] >> right[i];
    rep(i, q){
        ll r = lower_bound(idx.begin(), idx.end(), right[i]) - idx.begin();
        ll l = lower_bound(idx.begin(), idx.end(), left[i]) - idx.begin();
        cout << r - l << endl;
    }
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

vector<string> a(401);
int h, w;

bool mark[401][401];
int b[401][401];

ll c1, c2;
void dfs(int x, int y, int col)
{
	if (x < 0 or y < 0 or x >= h or y >= w) return;
	if (b[x][y] != col) return;
	if (mark[x][y]) return;
	mark[x][y] = 1;
	if (col) ++c2;
	else ++c1;
	dfs(x+1, y, col^1);
	dfs(x, y+1, col^1);
	dfs(x-1, y, col^1);
	dfs(x, y-1, col^1);
}

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	cin >> h >> w;
	for (int i = 0; i < h; ++i)
	{
		cin >> a[i];
		for (int j = 0; j < w; ++j)
		{
			if (a[i][j] == '.') b[i][j] = 0;
			else b[i][j] = 1;
		}
	}
	ll ans = 0;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (mark[i][j]) continue;
			c1 = c2 = 0;

			dfs(i, j, b[i][j]);
			ans += c1*c2;
		}
	}
	cout << ans;
}

Measured memory_bytes: 13696
solve(i,j){
  m[i][j]='0';
  if(m[i][j-1]-'0')solve(i,j-1);
  if(m[i-1][j]-'0')solve(i-1,j);
  if(m[i+1][j]-'0')solve(i+1,j);
  if(m[i][j+1]-'0')solve(i,j+1);
}

main(){
  int w=12,h=12,i,j,r;
  for(;;printf("%d\n",r)){
    memset(m,'0',sizeof(m));
    r=0;
    for(i=1;i<=h;m[i][13]='0',i++)
      if(scanf("%s",m[i]+1)==-1)return 0;
    for(i=1;i<=h;i++)
      for(j=1;j<=w;j++)
        if(m[i][j]-'0')solve(i,j),r++;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    if(A >= K){
        cout << K;
    } else if((A + B) >= K){
        cout << A;
    } else {
        cout << A * 2 - K + B;
    }
}

Measured memory_bytes: 3636