akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    // Your code here!
    
    int vector[101][101];
    int product[101];
    int a,b,i,j;
    scanf("%d %d",&a,&b);
    
    for(i=1;i<=a;i++){
        for(j=1;j<=b;j++){
            
            scanf("%d",&vector[i][j]);
           
        }
    }
    
    for(j=1;j<=b;j++){
        scanf("%d",&product[j]);
    }
    
    
    for(i=1;i<=a;i++){
        int sum=0;
        
        for(j=1;j<=b;j++){
        sum+=vector[i][j]*product[j];    
            
            
        }
        printf("%d\n",sum);
    }
    
    
    
    
    
}



Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;
int main() {
	int a, b;
	int n;
	cin >> a >> b;
	if (b / 100 > 0)n = 1000 * a + b;
	else if (b / 10 > 0)n = 100 * a + b;
	else n = 10 * a + b;
	//cout << n << endl;
	for (int i = 1; i < 1000; i++) {
		if (n % i == 0 && n / i == i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3492
import heapq
n,m=map(int,input().split())
item=list(map(lambda x: -int(x),input().split()))
heapq.heapify(item)
for i in range(m):
    a=-heapq.heappop(item)
    a //=2
    heapq.heappush(item,-a)

print(-sum(item))

Measured memory_bytes: 72216
// A - STring

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string X;
	cin >> X;

	stack<char> s;
	int cnt = 0;

	for (int i=0; i<X.size(); i++) {
		if (s.empty() == false) {
			if (s.top() == 'S' && X[i] == 'T') {
				cnt += 2;
				s.pop();
				continue;
			}
		}

		s.push(X[i]);
	}

	int ans = X.size() - cnt;;

	cout << ans << endl;

	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a != c || a == c && b != c || c == b && a != c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    repeat(i, n) {
        cin >> p[i];
        --p[i];
    }
    p.push_back(0);
        
    int ans = 0;
    bool closed = true;
    int len = 0;
    repeat(i, n + 1) {
        if (p[i] == i && closed) {
            closed = false;
            ++len;
        }
        else if (p[i] == i && not closed) {
            ++len;
        }
        else if (p[i] != i && not closed) {
            ans += (len + 1) / 2;
            len = 0;
            closed = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int a_max = -1, a_diff_max = -1, res = 0;
    for (int i = n - 1; i >= 0; i--) {
        a_max = max(a_max, a[i]);

        if (a_diff_max < a_max - a[i]) {
            a_diff_max = a_max - a[i];
            res = 1;
        } else if (a_diff_max == a_max - a[i]) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

const int maxn = 1010;
const double T = 16.020125;
const double pi = acos(-1.0);

double a[maxn];

int main() {
    int n;
    while(cin >> n) {
        int temp = n / 2;
        if(n%2 == 0) temp--;
        cout << temp << endl;
    }
    return 0;
}

//15.978 16.041 16.038 16.043 16.031 15.946 16.041 16.043


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 1050;

char s[N][N];
bool vis[N][N];
int n,m,tot,res,ex,ey;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int d[N][N];

void bfs(int x,int y,int cnt){
	memset(vis,false,sizeof(vis));
	queue<P>q;
	while(!q.empty()) q.pop();
	P sta;
	sta.fir=x,sta.sec=y;
	vis[x][y]=true;
	q.push(sta);
	while(!q.empty()){
		P p=q.front();
		q.pop();
		if(s[p.fir][p.sec]==cnt+'0'){
			if(cnt<tot) bfs(p.fir,p.sec,cnt+1);
			return;
		}
		for(int i=0;i<4;i++){
			int tx=p.fir+dx[i];
			int ty=p.sec+dy[i];
			if(!vis[tx][ty]&&s[tx][ty]!='X'&&tx>=1&&tx<=n&&ty>=1&&ty<=m){
				res++;
				vis[tx][ty]=true;
				q.push(P(tx,ty));
				d[tx][ty]=d[p.fir][p.sec]+1;
			}
		}
	}
}

int main(){
	scanf("%d%d%d",&n,&m,&tot);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='S') {bfs(i,j,1);}
			if(s[i][j]==tot+'0') ex=i,ey=j;
		}
	}
	printf("%d\n",d[ex][ey]);
	return 0;
}


Measured memory_bytes: 9420
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}

		boolean result = list.stream().allMatch(a -> a % 2 == 1 || a % 3 == 0 || a % 5 == 0);
		System.out.println(result ? "APPROVED" : "DENIED");
		scan.close();
	}
}

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

using namespace std;



typedef long long int ll;


bool is_prime(int n) {
    if (n == 1) {
        return false;
    }

    int i = 2;
    while (i * i <= n) {
        if (n % i == 0) {
            return false;
        }
        i += 1;
    }

    return true;
}
int main() {
    /*ll test{};
    cin >> test;
    cin.ignore();
    while (test--) {
        
        

    }*/
    ll x{}, y{};
    cin >> x >> y;
    if ((y >= 2 * x && 4 * x >= y) && ((y - 2 * x) % 2 == 0 && (4 * x - y) % 2 == 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    



    return 0;
}

Measured memory_bytes: 3620
program Popularvote;
var
    list : array[1..100] of Longint;
    x, y, i, j, total, select : Longint;

begin
    total := 0;
    select := 0;
    readln(x, y);
    for i := 1 to x do begin
        read(list[i]);
        total += list[i];
    end;
    for j := 1 to x do begin
        if list[j] >= (total / (y * 4)) then
            select += 1;
    end;
    if select >= y then 
        writeln('Yes')
    else
        writeln('No');
end.

Measured memory_bytes: 1388
H, W = map(int, input().split())
a = [str(input()) for i in range(H)]
sharp = str("#"*(W+2))

Lists = []
Lists.append([sharp])
for i in range(H):
    Lists.append(["#" + a[i] +"#"])

Lists.append([sharp])

for List in Lists:
    print(*List)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;
int num[50];


void showsort(int A[], int n)
{
  for(int i=0; i < n; i++){
    cout << A[i];
  }
  cout << endl;
}


void sort(int A[], int n)
{
  int temp;
  //cout << A[2] << endl;
  //cout << A[1] << endl;
  for(int i=0; i<n; i++){
    for(int j=n-1; j > i ; j--){ //for文の２つ目の引数は　""ループ実行できるための条件(この条件を満たす限りループを続けろってこと)""なので j < iにしたら初期条件からi=0,j=n-1より成り立たない．
      if( A[j-1] > A[j] ){
        temp = A[j-1];
        A[j-1] = A[j];
        A[j] = temp;
      }
    }
  }
  //showsort(A,n);
/*  for(int i=0; i < n; i++)
    cout << num[i];*/
}

int main(){

    int N,K;
    cin >> N >> K;

    for(int i=0; i < N; i++)
      cin >> num[i];

    sort(num,N);
  //  showsort(num,N);

    int sum=0;
      //cout << N<< K << endl;
    for(int i=N-1; i>N-K-1; i--)
       sum = sum + num[i];

    cout << sum << endl;

    /*cout<< N << " " << K << endl;
    for(int i=0; i < N; i++)
      cout << num[i] <<endl;*/

    return 0;

}


Measured memory_bytes: 256
n,k = map(int,input().split())
ab = []
for i in range(n):
    a, b = map(int,input().split())
    ab.append((a,b))

ab.sort()
ans = 0
for i in range(n):
    ans += ab[i][1]
    if ans >= k:
        print(ab[i][0])
        break


Measured memory_bytes: 16944
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    string s;
    cin >> s;

    vector<char> ans;
    for (char ch : s){
        if (ch == '0' || ch == '1') ans.push_back(ch);
        else {
            if (ans.size() > 0) ans.pop_back();
        }
    }

    for (auto a : ans){
        cout << a;
    }
    cout << endl;

    return 0;
}























Measured memory_bytes: 256
#include<bits/stdc++.h>
#define NewBlash using namespace std;
#define is int main(){char s[110];
#define so gets(s);
#define weak int l=strlen(s);
#define that for(int i=0,flag=0;i<l;i++){
#define everyone if(s[i]=='C') flag=1;
#define can if(s[i]=='F'&&flag){
#define beat printf("Yes");
#define him return 0;}}
#define easily printf("No");}
NewBlash is so weak that everyone can beat him easily

Measured memory_bytes: 256
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
import itertools
ans=float("inf")
for c in itertools.combinations(range(n),k):
  c=set(c)
  cur=0
  prev=0
  for i in range(n):
    if i not in c:
      prev=max(prev,A[i])
      continue
    else:
      if A[i]>prev:
        prev=A[i]
        continue
      else:
        cur+=prev-A[i]+1
        prev+=1
  ans=min(cur,ans)
print(ans)




Measured memory_bytes: 3064
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

ll n , x;

ll f(ll a,ll b) {
  if(a < b) swap(a , b);
  if(b == 0) return -a;
  return f(b , a % b) + (a / b) * b * 2;
}

int main(){
  cin >> n >> x;
  cout << n + f(n - x , x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;

int main()
{
    int N;
    vector<int> xored;
    int all;
    cin >> N;

    for(int i = 0; i < N; i++)
    {
        int v;
        cin >> v;
        xored.push_back(v);
        if(i == 0) all = v;
        else all = all ^ v;
    }
    for(int i = 0; i < N; i++)
    {
        int out = xored[i] ^ all;
        cout << out;
        if(i < N-1) cout << " ";
    }
    cout << "\n";
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
    string s;
    cin >> s;
    int cnt[2]={};
    rep(i, s.size()) {
        cnt[s[i] == 'p']++;
    }
    int ans = cnt[0] - cnt[1];
    ans /= 2;
    cout << ans << endl;

    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    int cnt[3]={};
    rep(i,s.size())cnt[s[i]-'a']++;
    sort(cnt,cnt+3);
    if(cnt[2]-cnt[0]<=1){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> rnum(n);

  for(int i = 0; i < m; i++){
      
      int a,b;
      cin >> a >> b;
      rnum.at(a-1)++;
      rnum.at(b-1)++;

  }
  
  for(int i = 0; i < n; i++){
      cout << rnum.at(i) << endl;
  }

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int max=a[0];
	int total = a[0] + a[1] + a[2];
	for (int i = 0;i < 3;i++) {
		if (max < a[i]) max = a[i];
	}
	if (max == total - max) cout << "Yes";
	else cout << "No";
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef long long ll;
//typedef pair<ll,ll> P;

//const int INF = 1001001001;
const long long INF = 2e18;
const int MOD = 1000000007;
const double PI=acos(-1);


//-------------------------------------------------ABC35D
struct edge{ll to, cost;};
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(int i=0; i<V; i++){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i=0; i<V; i++){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>, greater<pair<ll,ll>> > que; //first:dist from start, second:next v
    que.push(make_pair(0,s));
    while(!que.empty()){
      auto p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(make_pair(d[e.to],e.to));
        }
      }
    }
  }
};

int main() {
    ll N;
    cin >> N;

    graph g1(N),g2(N);

    rep(i,N-1) {
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        g1.add_edge(a,b,c);
        g1.add_edge(b,a,c);
    }

    int Q,K;
    cin >> Q >> K;
    K--;
    g1.dijkstra(K);

    rep(i,Q) {
        ll x,y;
        cin >> x >> y;
        x--,y--;
        cout << g1.d[x]+g1.d[y] << endl;
    }

}

Measured memory_bytes: 14704
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
int i,j,k;
int n;
int a[maxn],ha[maxn],t1,t2,t3,t4,t5,t6;
int main(){
	cin>>n;
	for (i=1;i<=n;i++){
		cin>>a[i];
	}
	t1=n; t3=n; t2=n; t4=n;
	for (i=2;i<=n;i=i+2){
		ha[a[i]]++;
	}
	for (i=0;i<maxn;i++){
		t1=min(t1,(n/2)-ha[i]);
		if (t3>t1){
			swap(t3,t1);
			t5=i;
		}
	}
	memset(ha,0,sizeof(ha));
	for (i=1;i<=n;i=i+2){
		ha[a[i]]++;
	}
	for (i=0;i<maxn;i++){
		t2=min(t2,(n/2)-ha[i]);
		if (t4>t2){
			swap(t4,t2);
			t6=i;
		}
	}
	if (t5!=t6) printf("%d\n",t3+t4);
	else{
		printf("%d\n",min(t1+t4,t3+t2));
	}
	return 0;
}

Measured memory_bytes: 4516
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int solve(int N, const vector<long long> &x, const vector<long long> &y, long long p, long long q)
{
	int ans = 0;
	vector<bool> used(N, false);

	for (int i = 0; i < N; ++i) {
		if (!used[i]) {
			used[i] = true;
			vector<long long> t;
			t.push_back(0);
			for (int k = 0; k < N; ++k) {
				if (!used[k]) {
					auto dx = x[k] - x[i];
					auto dy = y[k] - y[i];
					if (p == 0) {
						if (dx == 0 && dy % q == 0) {
							used[k] = true;
							t.push_back(dy / q);
						}
					}
					else if (q == 0) {
						if (dx % p == 0 && dy == 0) {
							used[k] = true;
							t.push_back(dx / p);
						}
					}
					else {
						if (dx % p == 0 && dy % q == 0 && dx / p == dy / q) {
							used[k] = true;
							t.push_back(dx / p);
						}
					}
					
				}
			}
			sort(t.begin(), t.end());

			//for (auto x : t) cout << x << ",";
			//cout << endl;

			int g = 1;
			for (auto k = 0u; k + 1 < t.size(); ++k) {
				if (t[k] + 1 != t[k + 1]) {
					++g;
				}
			}
			//cout << "g=" << g << endl;
			ans += g;
		}
	}
	//cout << "p=" << p << ", q=" << q << ": " << ans << endl;
	return ans;
}

int main()
{
	int N;
	cin >> N;
	vector<long long> x(N), y(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}

	int ans = N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i != j) {
				auto p = x[i] - x[j];
				auto q = y[i] - y[j];
				ans = min(ans, solve(N, x, y, p, q));
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;

class PersonInfo {
public:
	int id;
	int numberOfPeople;
	int arriveTime, eatTime;
};

int CounterTable[17], Ans[100];
vector<PersonInfo> PersonData;


void Init() {
	PersonInfo temp;

	for (int i = 0; i < 17; i++) {
		CounterTable[i] = 0;
	}
	memset(Ans, 0, sizeof(Ans));

	for (int i = 0; i < 100; i++) {
		temp.id = i;
		temp.numberOfPeople = (i % 5 == 1 ? 5 : 2);
		temp.arriveTime = i * 5;
		temp.eatTime = 17 * (i % 2) + 3 * (i % 3) + 19;
		PersonData.push_back(temp);
	}
	//cout << PersonData.size() << endl;
}


void clearCounterTable() {
	for (int i = 0; i < 17; i++) {
		if (CounterTable[i] != 0) {
			CounterTable[i]--;
		}
	}
}

bool isSitOK(int number, int eatTime) {
	bool flag;

	flag = false;
	for (int i = 0; i < 17; i++) {
		if (CounterTable[i] != 0) {
			continue;
		}
		for (int j = 1; j < number; j++) {
			if (i + j > 16 || CounterTable[i + j] != 0) {
				flag = false;
				break;
			}
			flag = true;
		}
		if (flag) {
			for (int j = 0; j < number; j++) {
				CounterTable[i + j] = eatTime;
			}
			return true;
		}
	}

	return false;
}

void showTable(int time) {
	printf("time[%03d]: ", time);
	for (int i = 0; i < 17; i++) {
		if (CounterTable[i] == 0) {
			cout << "*";
		}
		else {
			cout << CounterTable[i];
		}
	}
	cout << endl;

}

void solve() {
	int time;
	PersonInfo temp;

	time = 0;
	temp = PersonData[0];
	while (1) {
		clearCounterTable();
		while ( (temp.id != 0 && time >= temp.arriveTime) || temp.id == 0 ) {
			//cout << "currentTime:" << time << "  judgeID:" << temp.id << endl;
			if ( !isSitOK(temp.numberOfPeople, temp.eatTime) ) {
				break;
			}
			Ans[temp.id] = time - temp.arriveTime;
			PersonData.erase(PersonData.begin());
			if (PersonData.empty()) {
				return;
			}
			temp = PersonData[0];
		}
		//if (time % 5 == 0) {
		//	showTable(time);
		//}
		time++;
	}
}

int main() {
	int n;

	Init();
	solve();
	while (cin >> n) {
		cout << Ans[n] << endl;
	}

	return 0;
}



Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
int n , x[200000] , pos , ans , now;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> x[i];
	}
	now = 0;
	for(int i = 2 ; i <= n ; i++){
		if(now == 0){
			if(x[i] == x[i - 1])now = 0;
			if(x[i] > x[i - 1])now = 1;
			if(x[i] < x[i - 1])now = 2;
		}
		else if(now == 1){
			if(x[i] < x[i - 1]){
				now = 0;
				ans++;
			}
		}
		else if(now == 2){
			if(x[i] > x[i - 1]){
				now = 0;
				ans++;
			}
		}
	}
	cout << ans + 1 << endl;
}

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


int main(){
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(r<=x&&x<=w-r&&r<=y&&y<=h-r)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	 
	
	return 0;
}



Measured memory_bytes: 3116
#include<iostream>
main(){
  int n;
  std::cin>>n;
  int a=4,b=7;
  for(int i=0;i<=100;++i)
    for(int j=0;j<=100;++j)
      if(a*i+b*j==n){
        puts("Yes");
        return 0;
      }
  puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	bool ans=true;
	int t0=0,x0=0,y0=0;
	rep(i,n) {
		int t1,x1,y1;cin>>t1>>x1>>y1;
		if(!ans) continue;
		int dt=t1-t0,dx=abs(x1-x0),dy=abs(y1-y0);
		t0=t1;x0=x1;y0=y1;
		if(dt<dx+dy||dt%2!=(dx+dy)%2) {ans=false;}
	}
	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
dict = defaultdict(list)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    dict[b].append(a)

total = 0
for k, v in sorted(dict.items()):
    total += sum(v)
    if k < total:
        print("No")
        exit()


print("Yes")



Measured memory_bytes: 63876
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
 
	
	string S,an ="NO";
	cin >> S ;
	vector<string> vec = { "AKIHABARA","AKIHABAR", "AKIHABRA", "AKIHABR", "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR", "KIHABARA", "KIHABAR", "KIHABRA", "KIHABR", "KIHBARA", "KIHBAR", "KIHBRA", "KIHBAR", "KIHBR" };
	rep(j, 17) {
		if (S == vec.at(j)) {
			an = "YES";
		}
	}
	
	cout << an << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, m, a = 1;
    cin >> n >> m;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            if(m/i>=n && a < i) a = i;
            if(i>=n && a < m/i) a = m / i;
        }
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>

const int MOD = 2019;

int main() {
    int L, R;
    std::cin >> L >> R;

    int ans = MOD;
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            ans = std::min(ans, (i % MOD) * (j % MOD) % MOD);
            if (ans == 0) {
                std::cout << "0\n";
                return 0;
            }
        }
    }
    std::cout << ans << "\n";
}

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

solve :: Int -> Int -> [Int] -> Int
solve n m as =
  (\(x, _, _) -> x) $
    foldl
      ( \(p, pp, a) i ->
          if not (null a) && head a == i
            then (0, p, tail a)
            else ((p + pp) `mod` 1000000007, p, a)
      )
      (1, 0, as)
      [1 .. n]

main = do
  [n, m] <- getIntList
  as <- replicateM m getInt

  print $ solve n m as

Measured memory_bytes: 23492
import sys
from collections import defaultdict

n, m = map(int, sys.stdin.readline().split())
*A, = map(int, sys.stdin.readline().split())
BC = zip(*[map(int, sys.stdin.read().split())] * 2)

def main():
    res = defaultdict(int)
    for a in A:
        res[a] += 1
    
    for b, c in BC:
        res[c] += b

    ans = 0
    r = n
    for v, c in sorted(res.items(), reverse=True):
        if c <= r:
            r -= c
            ans += v * c
        else:
            ans += v * r
            break
    
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 47128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const int PI = acos(-1);
int main(){
	int n;cin>>n;string s1,s2;cin>>s1>>s2;
	ll ans =0;
	bool f ;
	if(s1[0]!=s2[0]){
		ans=6;
		f=true;
	}
	else{
		ans=3;f=false;
	}
	rep(i,n){
		if(i==0)continue;
		if(i==1&&s1[0]!=s2[0])continue;
		if(f){
			if(s1[i]!=s2[i]){
				f=true;
				ans*=3;
				i++;
			}	
			else{
				f=false;
				ans*=1;
			}
		}
		else{
			if(s1[i]!=s2[i]){
				f=true;
				ans*=2;
				i++;
			}	
			else{
				f=false;
				ans*=2;
			}
		}
		ans%=mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>
#include <cmath>

using namespace std;
using llong = long long;

using P = pair<long,long>;
long a[100000];

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

  sort(a,a+N);
  
  int min_dist = 1000000000, min_r;
  for(int i=0;i<N-1;++i){
    if(std::abs(a[i]-(a[N-1]+1)/2) < min_dist){
      min_dist = std::abs(a[i]-(a[N-1]+1)/2);
      min_r = a[i];
    }
  }

  cout << a[N-1] << " " << min_r << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	/** 計算する最大値 */
	private static final int N = 100_000;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// Nまでの素数を計算する
			boolean[] isPrime = new boolean[N + 1];
			Arrays.fill(isPrime, true);
			isPrime[0] = isPrime[1] = false;
			IntStream.rangeClosed(2, N).forEach(i -> {
				if (isPrime[i]) {
					IntStream.rangeClosed(2, N / i).forEach(j -> isPrime[j * i] = false);
				}
			});
			// 最大値まで2017に似た数を計算する
			int[] count = new int[N];
			count[0] = count[1] = count[2] = 0;
			IntStream.range(3, N).forEach(i -> count[i] = count[i - 1] + (is2017LikeNumber(i, isPrime) ? 1 : 0));
			int q = scanner.nextInt();
			IntStream.range(0, q).map(i -> {
				int l = scanner.nextInt();
				int r = scanner.nextInt();
				return count[r] - count[l - 1];
			}).forEach(System.out::println);
		}
	}

	/**
	 * 入力数字が2017に似た数であるかどうかを計算
	 * 
	 * @param number  入力数字
	 * @param isPrime indexが素数かどうかの配列
	 * @return 入力数字が2017に似た数であるかどうか
	 */
	private static boolean is2017LikeNumber(int number, boolean[] isPrime) {
		return (1 == (number & 1)) && isPrime[number] && isPrime[(number + 1) / 2];
	}
}


Measured memory_bytes: 67736
#include <iostream>

using namespace std;

int main( void ) {
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f) {
        double y = ((c*d - a*f) / (b*d - a*e));
        double x = ((c*e - f*b) / (a*e - b*d));
        int iy = (int)(y * 1000);
        int ix = (int)(x * 1000);
        y = iy / 1000.0; x = ix / 1000.0;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    int num[3];
    int i,j;

    for (i = 0; i <= 2; i++)
    {
        cin >> num[i];
    }

    int space;

    for (i = 0; i < sizeof(num) / sizeof(int) - 1; i++)
    {
        for (j = sizeof(num) / sizeof(int) - 1; j > i; j--)
        {
            if (num[j - 1] > num[j])
            {
                space = num[j - 1];
                num[j - 1] = num[j];
                num[j] = space;
            }
        }
    }

    cout << num[2] * 10 + num[1] + num[0];
    //cout << N;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include <bits/stdc++.h>
   
    using namespace std;
    const int MAXN = 100000;
    const int INF  = 0x3f3f3f3f;
    int main() {
        ios_base :: sync_with_stdio(false);
        cin.tie(NULL);
     
        long long N,W;
        cin>>N>>W;
        long val[N];
        long weight[N];
        for(int i=0;i<N;i++){
            cin>>val[i]>>weight[i];
        }
        //cout<<"shue"<<endl;
        vector<long long>dp(MAXN+1, INF);
        dp[0]=0;
        for(int i=0;i<N;i++){
            for(int j=MAXN;j>=weight[i];j--){
                // if(weight[j]>W)
                //     dp[i]=max(dp[i], val[i]);
                // else
                    dp[j]=min(dp[j], dp[j-weight[i]]+ val[i]);
            }
        }//cout<<dp[MAXN]<<"\n";
        long long ans=0;
        for(int i=MAXN;i>=0;i--){
            if(dp[i]<=W)
                ans=max(ans, (long long)i);
        }
     
        cout<<ans;
        return 0;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin >> n;
	int k = n;
	int sum = 0;
	while(k != 0){
		sum += k%10;
		k /= 10;
	}
	if(n%sum == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp
#include <iostream>

using namespace std;
const int KINDMAX = 21;
const int PAYMAX = 50001;
const int COINMAX = 10000;

int dp[PAYMAX][KINDMAX];
int coinMem[PAYMAX];
int main() {
  int pay, kind, coin[KINDMAX];
  cin >> pay >> kind;
  for (int i=0; i<kind; ++i) {
    cin >> coin[i];
  }

  for (int j=0; j<=pay/coin[0]; ++j) {
    dp[j*coin[0]][0] = j;
    if (kind==1) continue;
    //coinMod[ (j*coin[0])%(coin[1]) ]++;

  }
  for (int i=1; i<kind; ++i) {
    for (int j=0; j<=pay; ++j) {
      coinMem[j] = 0;
    }
    int dpi = i;
    for (int j=0; j<=pay/coin[i]; ++j) {
      dp[j*coin[i]][dpi] = j;
    }
    for (int j=1; j<=pay; ++j) {
      int back = j-coin[i];
      if (back > 0 && dp[back][dpi-1] != 0) {
        if (coinMem[back] == 0) {
          int q = dp[back][dpi-1] + 1;
          if (dp[j][dpi]==0 || q < dp[j][dpi]) dp[j][dpi] = q;
          coinMem[j] = q;
        } else {
          int q = dp[back][dpi-1] + 1;
          int r = coinMem[back] + 1;
          coinMem[j] = q<r? q:r;
          if (dp[j][dpi]==0 || coinMem[j] < dp[j][dpi]) dp[j][dpi] = coinMem[j];
        }
      }
      if (dp[j][dpi-1] != 0) {
        if (dp[j][dpi] != 0 && dp[j][dpi] < dp[j][dpi-1]) {
          continue;
        } else {
          dp[j][dpi] = dp[j][dpi-1];
        }
      }
    }
  }
  cout << dp[pay][kind-1] << endl;
/*
  for (int i=0; i<=pay; ++i) {
    for (int j=0; j<kind; ++j) {
      cerr << dp[i][j] << "\t";
    }
    cerr << endl;
  }
  */
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

int A[1005];

bool check(int k)
{
    vector<int> v;
    while(k>0){
        v.push_back(k%10);
        k/=10;
    }
    REP(i,v.size()-1){
        if(v[i]-1==v[i+1]) continue;
        return false;
    }
    return true;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;
    int ans=-1;
    REP(i,n) cin>>A[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int p=A[i]*A[j];
            if(check(p)) ans=max(ans,p);
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3232
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define BUFSIZE 100000	


int n;
int h[BUFSIZE] = {0};
int dp[BUFSIZE] = {0}; 

int min(int a,int b){
  if(a > b) return b;
  else return a;
}


int main(void){
   scanf("%d",&n);
   for(int i = 0;i < n;i++) scanf("%d",&h[i]);
  
   dp[0] = 0; dp[1] = abs(h[1] - h[0]);
   for(int i = 2;i < n;i++)
	dp[i] = min(dp[i-1] + abs(h[i] - h[i - 1]),dp[i-2] + abs(h[i] - h[i-2]));


  
   printf("%d\n",dp[n-1]);

}

 


Measured memory_bytes: 2456
import sys
b=0
a=[{},{}]
for e in sys.stdin:
 if'\n'==e:b=1
 else:
  c=int(e.split(',')[0])
  if c in a[b]:a[b][c]+=1
  else:a[b][c]=1
for k in sorted({*a[0]}&{*a[1]}):print(k,a[0][k]+a[1][k])


Measured memory_bytes: 5600
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

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

void Ok()
{
    long long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n,sum,ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag,div,rcv,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[1013],bbb[1013],ccc[1013],alpbt;
    long long int sum_again;
    string spc;

    cin>>aaa;
    if(aaa[0]=='A' && aaa[1]=='B' && aaa[2]=='B')
        cout<<"Yes"<<endl;
    else if(aaa[0]=='B' && aaa[1]=='A' && aaa[2]=='A')
        cout<<"Yes"<<endl;
    else if(aaa[0]=='B' && aaa[1]=='A' && aaa[2]=='B')
        cout<<"Yes"<<endl;
    else if(aaa[0]=='A' && aaa[1]=='B' && aaa[2]=='A')
        cout<<"Yes"<<endl;
    else if(aaa[0]=='B' && aaa[1]=='B' && aaa[2]=='A')
        cout<<"Yes"<<endl;
    else if(aaa[0]=='A' && aaa[1]=='A' && aaa[2]=='B')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){

	
int H,W,i,j,k;
	for (i=0;i<=1;){
		scanf ("%d %d",&H,&W);
		if (H==0||W==0){
		break;
		}
		for (j=0;j<H;j++){
			for (k=0;k<W;k++){
				printf ("#");
			}
			printf ("\n");
		}
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<stdio.h>

int main()
{
	int n,i,q;long a[200001];
	while(scanf("%d",&n)==1)
	{
		for(i=1;i<=n;i++)
		{
			scanf("%ld",&a[i]);
		}
			for(q=n;q>=1;q-=2)
				printf(q==1||q==2?"%ld":"%ld ",a[q]);
			if(n%2==0) q=1;else q=2;
			for(;q<n;q+=2)
				printf(q==n-1?" %ld\n":" %ld",a[q]);
			if(n==1) printf("\n");
	}
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    string str;
    cin>>str;
    if(str == "#") break;
    int y, m, d;
    cin>>y>>m>>d;

    if(y > 31) str = "?", y -= 30;
    else if(y == 31){
      if(m > 4) str = "?", y -= 30;
      else if(m == 4){
	if(d > 30) str = "?", y -= 30;
      }
    }
    cout<<str<<" "<<y<<" "<<m<<" "<<d<<endl;

  }
  return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int H = nextInt();
  int W = nextInt();
  vector<string> s(H);
  REP(i, H) cin >> s[i];

  bool yes = true;
  REP(i, H) REP(j, W) {
    if (s[i][j] == '#') {
      int k = 0;
      if (j+1 < W && s[i][j+1] == '#') k++;
      if (j-1>=0 && s[i][j-1] == '#') k++;
      if (i+1 < H && s[i+1][j] == '#') k++;
      if (i-1 >= 0 && s[i-1][j] == '#') k++;
      if (k == 0) yes = false;
    }
  }
  cout << (yes ? "Yes":"No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
  string S;
  int ans = 0, tmp = 0;
  cin >> S;
  for (char c : S) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      tmp++;
    }
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
}

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


int main(){
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size()/2; ++i){
        if(s[i] != s[s.size()- (i+1)]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>

using namespace std;

double distance(pair<double, double> a, pair<double, double> b) {
    return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
}

pair<double, double> point(double l, double a) {
    a *= M_PI / 180;
    return {l * cos(a), l * sin(a)};
}

int main() {
    ios::sync_with_stdio(false);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    cout << setprecision(20) << distance(point(a, h * 30 + m * 0.5), point(b, m * 6)) << endl;
    return 0;
}


Measured memory_bytes: 4088
#include <string.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <fstream>
#include <iostream>
#define mod 1000000007
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
const double pi=3.141;
int main()
{
int r;
cin>>r;
cout<<double(2.0*r*pi);
}


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

typedef long long ll;

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; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b >= c) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int B = 65, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

int v[B][3], n;
vector<int> N;
void tovec()
{
    int tmp = n;
    while(tmp)
    {
        N.pb(tmp%2);
        tmp/=2;
    }
    N.pb(0);
    reverse(N.begin(), N.end());
}
int solve()
{
    tovec();
    v[0][0] = 1;
    for(int i = 1; i < N.size(); i++)
    {
        v[i][0] = (v[i-1][0] + v[i-1][1]*(N[i]==0))%MOD1;
        v[i][1] = ((N[i]==1)*v[i-1][0] + v[i-1][1])%MOD1;
        int k2 = 1 + (N[i]==1);
        v[i][2] = (3*v[i-1][2] + k2*v[i-1][1])%MOD1;
    }
    int nn = N.size()-1;
    return (v[nn][0] + v[nn][1] + v[nn][2])%MOD1;
}
signed main()
{
    cin >> n;
    cout << solve();
}

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

int main() {
    string aaa;
    getline(cin, aaa);
    std::string str1 = "coffee";

  std::string substr1 = str1.substr(2, 1);
  std::string substr2 = str1.substr(3, 1);
  std::string substr3 = str1.substr(4, 1);
  std::string substr4 = str1.substr(5, 1);
  std::string substr5 = aaa.substr(2, 1);
  std::string substr6 = aaa.substr(3, 1);
  std::string substr7 = aaa.substr(4, 1);
  std::string substr8 = aaa.substr(5, 1);
  
  if(substr1 == substr2 && substr3 == substr4){
    if(substr5 == substr6){
      if(substr7 == substr8){
      cout << "Yes" << endl;
      }else{
       cout << "No" << endl;
      }
    }else{
    cout << "No" << endl;
    }
         }else{
           cout << "No" << endl;
         }
    return 0;
  }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B>C+D){
    cout << "Left";
  }
  else if(A+B==C+D){
    cout << "Balanced";
  }
  else{
    cout << "Right";
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int a, b, n, i;
	string s;

	cin >> a >> b >> s;
	for (i = 0; i < a + b + 1; i++) {
		if (i == a) {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (!(s[i] == '0' ||
				s[i] == '1' ||
				s[i] == '2' ||
				s[i] == '3' ||
				s[i] == '4' ||
				s[i] == '5' ||
				s[i] == '6' ||
				s[i] == '7' ||
				s[i] == '8' ||
				s[i] == '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() 
{
    the_flash;
    int d, t, s;
    cin >> d >> t >> s;

    if (t * s >= d)
        cout << "Yes" << "\n";

    else 
        cout << "No" << "\n";
    return 0;
}

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

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

  queue<int> que;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    que.push(a);
    if (i >= K) {
      int p = que.front();
      que.pop();
      if (a > p)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 4368
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
vector<vector<pair<int, int> > > a(100000);

void dfs(int root, vector<int>& dis){
  vector<bool> visited(100000, false);
  stack<int> s;
  s.push(root);
  visited[root] = true;
  dis[root] = 0;
  while(s.size() > 0){
    int current = s.top();
    //cout << current << " ";
    s.pop();
    for(int i = 0; i < a[current].size(); i++){
      int next = a[current][i].first;
      int kyori = a[current][i].second;
      if(visited[next] == false){
        s.push(next);
        visited[next] = true;
        dis[next] = dis[current] + kyori;
      }
    }
  }
  //cout << endl;
  return;
}

int getmaxi(vector<int>& dis){
  int maxi = 0;
  for(int i = 1; i < n; i++){
    if(dis[i] > dis[maxi]){
      maxi = i;
    }
  }
  return maxi;
}

void solve(){
  cin >> n;
  for(int i = 0; i < n - 1; i++){
    int s, t, w; cin >> s >> t >> w;
    a[s].push_back(make_pair(t, w));
    a[t].push_back(make_pair(s, w));
  }
  vector<int> dis(100000);
  dfs(0, dis);
  int maxi = getmaxi(dis);
  vector<int> dis2(100000);
  dfs(maxi, dis2);
  maxi = getmaxi(dis2);
  cout << dis2[maxi] << endl;

  return;
}

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



Measured memory_bytes: 9896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("/usr/local/google/home/absajwan/input_file.in", "r", stdin); freopen("/usr/local/google/home/absajwan/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pll a, pll b)//true for a before b
{
	return ((a.S*b.F) <= (b.S*a.F));
}

const int N = (3e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 650;

string s;
int sum[N];

int east(int l, int r)
{
	if(l > r)
		return 0;
	return (sum[r]-sum[l-1]);
}

int west(int l, int r)
{
	if(l > r)
		return 0;
	return (r-l+1 - east(l,r));
}

void solve()
{
	int n, i, ans = INF, val;
	cin >> n;
	cin >> s;
	fo(i,0,n)
	{
		sum[i+1] = sum[i];
		if(s[i] == 'E')
			sum[i+1]++;
	}
	fo(i,1,n+1)
	{
		val = west(1,i-1) + east(i+1,n);
		ans = min(ans, val);
	}
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here

	int t = 1, cs;
	// cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}

	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}


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

int main() {
  int N, a,b,s;
  cin >> N;
  s=0;
  for (int i=0; i<N; i++){
  cin >>a>>b;
  s+= b - a + 1 ;
  }
  cout << s <<endl;
}


Measured memory_bytes: 256