akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
int a[100005];
rep(i,1,n)cin>>a[i];
int ans=0;
rep(i,1,n-1)
{
	if(a[i]==i)
	{
		ans++;
		swap(a[i],a[i+1]);
	}
}
if(a[n]==n)ans++;
ol(ans);
return 0;
}



Measured memory_bytes: 640
n=int(input())
l=list(map(int,input().split()))
l.sort()
if l[0]>=0 :
  print(sum(l)-2*l[0])
  for i in range(1,n-1):
    print(l[0],l[i])
    l[0]-=l[i]
  print(l[-1],l[0])
elif l[-1]<0:
  print(abs(sum(l)-2*l[-1]))
  for i in range(n-1):
    print(l[-1],l[i])
    l[-1]-=l[i]
else:
  cnt=0
  i=0
  while l[i]<0:
    cnt+=1
    if l[i+1]>=0:
      break
    i+=1
  ans=0
  for j in range(n):
    ans+=abs(l[j])
  print(ans)
  for j in range(n-2-i):
    print(l[0],l[i+j+1])
    l[0]-=l[i+j+1]
  for j in range(i+1):
    print(l[-1],l[j])
    l[-1]-=l[j]
    


Measured memory_bytes: 14260
#include<bits/stdc++.h>
using namespace std;
#define MN 18
int a[1<<MN],b[1<<MN],c[1<<MN],d[1<<MN];
inline void rw(int x,int y)
{
	if(x!=b[y])if(a[x]>a[b[y]])c[y]=b[y],b[y]=x;
	else if(x!=c[y]&&a[x]>a[c[y]])c[y]=x;
}
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<1<<n;++i)scanf("%d",&a[i]);
	for(i=1;i<1<<n;++i)(a[i]>a[0]?b:c)[i]=i;
	for(i=1;i<1<<n;++i)for(j=0;j<n;++j)rw(b[i],i|(1<<j)),rw(c[i],i|(1<<j));
	for(i=1;i<1<<n;++i)printf("%d\n",d[i]=max(d[i-1],a[b[i]]+a[c[i]]));
}

Measured memory_bytes: 7168
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll x;
    cin>>x;
    if(x>=30)
    cout<<"Yes";
    else
    cout<<"No";}
    
    
    
    
   

Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
  int D;
  cin>>D;
  if(D==25){
    cout<<"Christmas";
  }
  if(D==24){
    cout<<"Christmas Eve";
  }
  if(D==23){
    cout<<"Christmas Eve Eve";
  }
  if(D==22){
  	cout<<"Christmas Eve Eve Eve";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 888
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int count = 0;
        for (int i = 0; i < 4; i++) {
            if (n.charAt(i) == '2') {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}


signed main(){
    string s;
    cin >> s;

    vector<vector<string>> v = {{"AKI", "HA", "BA", "RA"},
                                {"KI", "H", "B", "R"}};

    bool ok = false;

    for(int bit = 0; bit < (1 << 4); bit++){
        string t;
        REP(i, 4){
            t += v[(bit >> i) & 1][i];
        }
        if(s == t) ok = true;
    }

    cout << (ok ? "YES" : "NO") << endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	
	static int INF = 1000000000;
	static int MAXN = 31;
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[][] point = new int[n][2];
		for (int i = 0; i < n; ++i) {
			point[i][0] = input.nextInt();
			point[i][1] = input.nextInt();
		}
		boolean ok = true;
		for (int i = 1; i < n - 2; ++i) {
			int ccw1 = ccw(point[i - 1], point[i], point[i + 1]);
			int ccw2 = ccw(point[i], point[i + 1], point[i + 2]);
			if (ccw1 * ccw2 < 0) {
				ok = false;
				break;
			}
		}
		int ccw1 = ccw(point[n - 2], point[n - 1], point[0]);
		int ccw2 = ccw(point[n - 1], point[0], point[1]);
		if (ccw1 * ccw2 < 0) {
			ok = false;
		}
		if (ok) System.out.println(1);
		else System.out.println(0);
	}
	
	static int ccw(int[] p1, int[] p2, int[] p3) {
		int a1, b1;
		int a2, b2;
		a1 = p2[0] - p1[0];
		b1 = p2[1] - p1[1];
		a2 = p3[0] - p2[0];
		b2 = p3[1] - p2[1];
		return a1 * b2 - a2 * b1;
	}
}

Measured memory_bytes: 20336
dice=input().split()
process=input()

do = {'N': (2,6,3,4,1,5),'S': (5,1,3,4,6,2),'E':(4,2,1,6,5,3),'W': (3,2,6,1,5,4)}

for x in process:
    dice=[dice[y-1] for y in do[x]]
print(dice[0])


Measured memory_bytes: 5568
s = input()
char_set = set(list(s))

ans = len(s)

for c in char_set:
    tmp = s
    cnt = 0
    while any(a != c for a in tmp):
        cnt += 1
        _tmp = ''
        for a, b in zip(tmp, tmp[1:]):
            if a == c or b == c:
                _tmp += c
            else:
                _tmp += b
        tmp = _tmp
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vl p(n); rep(i,n) cin >> p[i];
	ll mn = n+1;
	ll ans = 0;
	rep(i,n){
		if(p[i]<mn){
			ans++;
			mn = p[i];
		}
	}
	cout << ans << endl;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

ll pows(int a , int b)
{
	ll res=1;
	for(int i=0; i<b; ++i)
	{
		res*=a;
	}
	return res;
}

vi dp(100001,-1);
vi price;
int k;
int dpx(int n)
{
	ll mini=pows(10,10);
	if(n==1)
		return dp[1];
	if(n==2)
		return dp[2];
	if(dp[n]==-1)
	{
		for(int i=1; i<=k; ++i)
		{
			if(dp[n-i]==-1 && (n-i)>0)
			{
				dp[n-i]=dpx(n-i);
			}
		}
		for(int i=1; i<=k; ++i)
		{
			if(mini>(dp[n-i]+abs(price[n]-price[n-i])) && (n-i)>0)
			{
				mini=dp[n-i]+abs(price[n]-price[n-i]);
			}
		}
		dp[n]=mini;
		return dp[n];
	}
	else
		return dp[n];
}

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;
    cin>>n>>k;
    price.pb(0);
    for(int i=0; i<n; ++i)
    {
    	int x;cin>>x;price.pb(x);
    }
    dp[1]=0;
    dp[2]=abs(price[1]-price[2]);
    //dpx(n);
    for(int i=3; i<=n; ++i)
    {
    	ll mini=pows(10,10);
    	for(int j=1; j<=k; ++j)
    	{
    		if(i-j>0)
    		{
    			if(mini>(dp[i-j]+abs(price[i]-price[i-j])))
    				mini=dp[i-j]+abs(price[i]-price[i-j]);
    		}
    		dp[i]=mini;
    	}
    }
    cout<<dp[n]<<"\n";

}

Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A.at(i);

    int ate_sum = 0;

    for(int i = 0; i < N; i++){
        for(int coef = 0;; coef++){
            if(coef * A.at(i) + 1 > D) break;
            ate_sum++;
        }
    }
    cout << ate_sum + X << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPE(i,a,n) for(int i=a;i<=n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

int atcoder(){
    //入力
    int a,b,c;
    cin >> a >> b >> c;
    map<int,int> mp;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    bool ans = mp[5]==2 && mp[7]==1;
    
    YESNO(ans);
    
    return 0;
}

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


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

int main(){
    char ch;
    int num[26]={};
    
    while(cin>>ch){
        ch=tolower(ch);
        if(isalpha(ch)){
            num[ch-'a']+=1;
        }
    }
    for(int i=0;i<=25;i++){
        printf("%c : %d\n", i+'a',num[i]);
        
    }
    return 0;
    }
    


Measured memory_bytes: 3180
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int m = nm[1];
    int[][] a;
    for (int i = 0; i < m; i++) a ~= readints;

    // 各区間の右端の位置でソート
    a.sort!((a, b) => a[1] < b[1]);

    int ans = 0;
    int p = -1; // 切断した位置
    foreach (e; a) {
        // 切断した区間に含まれないので、新しい切断が必要
        if (p < e[0]) {
            // 切断位置を更新
            p = e[1] - 1;
            ans++;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 15100
#include <bits/stdc++.h>
using namespace std;
const long long K = 1e9;

int main(){
    long long S;
    cin >> S;
    if (S == 1e18) {
        cout << "0 0 1000000000 0 0 1000000000" << endl;
        return 0;
    }
    long long x[3], y[3];
    x[0] = 0; x[1] = K; y[0] = 0; y[1] = 1;
    x[2] = (K - (S%K)); y[2] = (S/K)+1;
    cout << "0 0 1000000000 1 " << x[2] << " " <<  y[2] << endl;
    return 0;
}

Measured memory_bytes: 256
number = list(input().split())

alist = []
for i in range(1,1000000000):
    mod = int(number[0]) * i % int(number[1])
    if mod == int(number[2]):
        print("YES")
        break
    if mod in alist:
        print("NO")
        break
    alist.append(mod)
    

Measured memory_bytes: 3060
N, A, B = map(int, input().split())
S = str(input())
 
total = 0
kaigai = 0
 
for i in range(0, len(S)):
    if S[i] == 'a':
        if total < A+B:
            print('Yes')
            total += 1
        else:
            print('No')
    elif S[i] == 'b':
        if total < A+B and kaigai <B:
            print('Yes')
            total += 1
            kaigai += 1
        else:
            print('No')
    else:
        print('No')
    
    

Measured memory_bytes: 4016
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define gcd __gcd
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// ve<ve<要素の型>> 変数名(縦, ve<要素の型>(横, 初期値))

int main() {
  ld N, a = 0;
  ci(N);
  rep(i, N){
    ld x;
    st y;
    ci(x, y);
    if(y == "JPY"){
      a += x;
    }
    else{
      a += x * 380000;
    }
  }
  sp(10);
  co(a);
}

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

int main(){
	int n;
	signed long int sum = 0;
	int i = 0;
	cin >> n;

	while(i < n){
		i++;
		if(i % 3 != 0){
			if(i % 5 != 0){
				sum += i;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3576
# https://atcoder.jp/contests/abc137/tasks/abc137_d

# 最終日に選ぶことができるのは、Ai=1だけ
# 最終-1日に選ぶことができるのは、Ai=1,2だけ

from collections import defaultdict
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
d = defaultdict(list)
queue = []

for _ in range(n):
    a, b = map(int, input().split())
    d[a].append(b)

ans = 0
for i in range(1, m + 1):
    for j in d[i]:
        heappush(queue, -j) # j日目までを全部push
    if len(queue) > 0: # 取れたら最大を取ってきて足す
        ans += heappop(queue) * -1

print(ans)

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

using namespace std;

struct node{

	long long int a,b;

};

bool cmp(node e,node f)

{

	if(e.a!=f.a)

	return e.a<f.a;

	else

	return e.b>f.b;

}

int main(){

long long int n,m,y=0;

cin>>n>>m;

node d[n+1];

for(int i=1;i<=n;i++)

cin>>d[i].a>>d[i].b;

sort(d+1,d+n+1,cmp);

for(int i=1;i<=n;i++){

	if(d[i].b<m)

	{

		y+=d[i].a*d[i].b;

		m-=d[i].b;

	}

	else

	{

		y+=d[i].a*m;

		break;

	}

}

cout<<y;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	string s;
	string s2;
	cin>>s;

	int t=s.size()-1;
	rep(i,s.size()){
		s2[i]=s[t];
		t--;
	}

	int total=0;
	rep(i,s.size()){
		if(s[i]!=s2[i])total++;
		t--;
	}
	cout<<total/2<<endl;
	return 0;

}



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

int main() {
  int a[101];
  int n, max;
  memset(a, 0, sizeof(int)*101);
  while (cin >> n) a[n]++; 
  for (int i=0; i<=100; i++) {
    if (a[i] > max) max = a[i];
  }
  for (int i=0; i<=100; i++) {
    if (a[i] == max) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python
# -*- coding: utf-8 -*-

mcxi = {'m' : 1000,'c' : 100, 'x': 10, 'i': 1}
mcxi_inv = dict(zip(mcxi.values(),mcxi.keys()))
def mcxi2num(text):
    num = 0
    n = 1
    for i in text:
        if i.isnumeric():
            n = int(i)
        else:
            num += n * mcxi[i]
            n = 1
    return num

n = int(input())
for i in range(n):
    a,b = input().split()
    num = mcxi2num(a)+mcxi2num(b)
    ans = ''
    for n in list(reversed(sorted(mcxi.values()))):
        ans += str(num // n) if num // n != 0 and num // n != 1 else ''
        ans += mcxi_inv[n] if num // n != 0 else ''
        num -= n * (num // n)
    print(ans)

Measured memory_bytes: 6724
S = input()
maxlen=count=0
isT = True
for i in range(len(S)):
  if S[i] == "T":
    isT = True
  if S[i] == "T" or S[i] == "G" or S[i] == "C" or S[i] == "A":
    count += 1
  else:
    if isT and maxlen < count:
      maxlen = count
    count = 0
    isT = False
    
if isT and maxlen < count:
  maxlen = count

print(maxlen)

Measured memory_bytes: 3064
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 自作プログラムテスト
{
    class Program
    {
        const int mod = 100000007;

        static void Main(string[] args)
        {
            string C = ReadLine();
            char ans = ' ';

            switch (char.Parse(C)) 
            {
                case 'a':
                    ans = 'b';
                    break;
                case 'b':
                    ans = 'c';
                    break;
                case 'c':
                    ans = 'd';
                    break;
                case 'd':
                    ans = 'e';
                    break;
                case 'e':
                    ans = 'f';
                    break;
                case 'f':
                    ans = 'g';
                    break;
                case 'g':
                    ans = 'h';
                    break;
                case 'h':
                    ans = 'i';
                    break;
                case 'i':
                    ans = 'j';
                    break;
                case 'j':
                    ans = 'k';
                    break;
                case 'k':
                    ans = 'l';
                    break;
                case 'l':
                    ans = 'm';
                    break;
                case 'm':
                    ans = 'n';
                    break;
                case 'n':
                    ans = 'o';
                    break;
                case 'o':
                    ans = 'p';
                    break;
                case 'p':
                    ans = 'q';
                    break;
                case 'q':
                    ans = 'r';
                    break;
                case 'r':
                    ans = 's';
                    break;
                case 's':
                    ans = 't';
                    break;
                case 't':
                    ans = 'u';
                    break;
                case 'u':
                    ans = 'v';
                    break;
                case 'v':
                    ans = 'w';
                    break;
                case 'w':
                    ans = 'x';
                    break;
                case 'x':
                    ans = 'y';
                    break;
                case 'y':
                    ans = 'z';
                    break;
            }

            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string S;
  cin >> S;
  int ans = 0;
  for(int i=0;i<4;i++){
    if(S[i]=='+') ans++;
    else ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
n_list = [[] for i in range(n)]
m_list = []

for i in range(n):
    n_list[i] = (list(map(int,input().split())))
for _ in range(m):
    m_list.append(int(input()))

for n_l in n_list:
    sum_n = 0
    for i in range(len(n_l)):
        sum_n += n_l[i]*m_list[i]
    print(sum_n)



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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define pii pair<int,int>
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;


void solve()    {
        string s;       cin>>s;
        if(s[0]=='7' or s[1]=='7' or s[2]=='7')         cout<<"Yes";
        else cout<<"No";
}
/*  Integer Overflow  */
int main()  {
    fast;
    //test()
        solve();
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

ll choose2(ll n) {
  assert(n > 1);
  return n * (n - 1) / 2;
}

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

  ll ans = 0;
  // N,N は何通りあるか？
  if (N > 1) {
    ans += choose2(N);
  }
  // M, Mは何通りあるか？
  if (M > 1) {
    ans += choose2(M);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
const int maxN = 3007;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;
int val[maxN], q[maxN], tt;
bool f[maxN];

struct vec {
	static const int maxE = maxN;
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxE << 1];
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { push(x, y), push(y, x); }
	inline int& operator () (int x) { return g[x]; }
	inline edge& operator [] (int x) { return e[x]; }
}e;

void dfs(int x, int fa) {
	f[x] = 0;
	fore (e, x, y) if (y != fa) {
		dfs(y, x);
		if (f[y] == 0 && val[x] > val[y]) f[x] = 1;
	}
}

int main() {

	n = ri();
	rep (i, 1, n) val[i] = ri();
	For (i, 1, n) e.link(ri(), ri());

	rep (i, 1, n) {
		dfs(i, 0);
		if (f[i]) q[++tt] = i;
	}
	
	rep (i, 1, tt) printf("%d%c", q[i], " \n"[i == tt]);

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int r , f ,g  ,e ;
    cin >> r >> f >> g >> e ;
    cout << r + f + g + e << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#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() {
    ll a, b, k; cin >> a >> b >> k;
    for (int i = 0; i < k; i++)
    {
        if (i % 2 == 0) {
            if (a % 2 == 1) a--;
            b += a / 2;
            a /= 2;
        } else {
            if (b % 2 == 1) b--;
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3552
import math
import sys

a = sys.stdin.readline().split(' ')
n = int(a[0])
m = int(a[1])

modulator = 1000000007

if n == m:
	print((math.factorial(n) * math.factorial(m) * 2) % modulator)
elif abs(n - m) == 1 :
	print((math.factorial(n) * math.factorial(m)) % modulator)
else:
	print(0)


Measured memory_bytes: 5192
//
// Created by kuribohkute on 20/04/2019.
//
#include <unordered_map>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define mp make_pair
#define X first
#define Y second

int main () {
    int n, l;
    cin >> n >> l;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += l + i - 1;
    }
    int mn = 1000000000;
    int res = sum;
//    cout << sum << "\n";
    for (int i = 1; i <= n; i++) {
        int fl = l + i - 1;
        int tmp = sum - fl;
        if (abs(tmp - sum) < mn) {
            mn = abs(tmp - sum);
            res = tmp;
        }
    }
    cout << res;
    return 0;
}


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

using ll=long long; 

void solve(){
	int n,k;
	cin>>n>>k;
	int ans=1;
	for(int i=0; i<n; i++){
		int n1, n2;
		n1=ans+k;
		n2=ans*2;
		if(n1>n2){
			ans=n2;
		}else{
			ans=n1;
		}
	}
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#
# abc128 c
#

import sys
from io import StringIO
import unittest
from collections import deque


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2
2 1 2
1 2
0 1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3
2 1 2
1 1
1 2
0 0 1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 2
3 1 2 5
2 2 3
1 0"""
        output = """8"""
        self.assertIO(input, output)


def resolve_bit():
    N, M = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        m = 0
        for i in range(M):
            t = 0
            for j in range(1, S[i][0]+1):
                if bit & (1 << (S[i][j]-1)):
                    t += 1
            if t % 2 != P[i]:
                break
            else:
                m += 1
        if m == M:
            ans += 1
    print(ans)


def resolve():
    global N, M, KS, P
    N, M = map(int, input().split())
    KS = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))

    ONS = deque()
    print(dfs(0, ONS))


def dfs(n, T):
    if n == N:
        onm = 0
        for i, ks in enumerate(KS):
            k, s = ks[0], ks[1:]
            onsn = 0
            for t in T:
                if t in s:
                    onsn += 1
            if onsn % 2 != P[i]:
                break
            else:
                onm += 1
        if onm == M:
            return 1
        else:
            return 0

    ans = 0
    T.append(n+1)
    ans += dfs(n+1, T)
    T.pop()
    ans += dfs(n+1, T)
    return ans


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Blackjack
            var A = ReadLine();

            if (A.Sum() <= 21)
            {
                Console.WriteLine("win");
            }
            else
            {
                Console.WriteLine("bust");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
n=int(input())
a=list(reversed(list(input())))
b=list(reversed(list(input())))
c=list(reversed(list(input())))
ans=0
for i in range(n):
    if a[i]==b[i] and b[i]==c[i]:
        continue
    elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        ans+=1
    else:
        ans+=2
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    string s;
    cin >> s;
    string ans;
    rep(i, s.size())
    {
        if (s[i] != 'B')
        {
            ans = ans + s[i];
        }
        else
        {
            if (!ans.empty())
                ans.pop_back();
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
struct point {
    double x, y;
    int d;
};
 
bool check_dst(point home, point ums, double a) {
 
    double x = home.x - ums.x;
    double y = home.y - ums.y;
 
    return x * x + y * y <= a * a;
 
}
 
bool check_deg(point home, point ums, double w) {
 
    double x = home.x - ums.x;
    double y = home.y - ums.y;
    double home_deg;
    double start_deg = w - ums.d / 2.0;
    double end_deg = w + ums.d / 2.0;
 
    home_deg = atan2(y, x) * 180 / M_PI;
 
    if(home_deg < 0.0) {
        home_deg += 360.0;
    }
 
    if(0.0 <= start_deg && end_deg <= 360.0) {
        return start_deg <= home_deg && home_deg <= end_deg;
    } else if(start_deg < 0.0) {
        start_deg += 360.0;
        return start_deg <= home_deg || home_deg <= end_deg;
    } else { // end_deg > 360
        end_deg -= 360.0;
        return start_deg <= home_deg || home_deg <= end_deg;
    }
 
}

bool check_reach(point home, point ums, double w, double a) {
    return check_deg(home, ums, w) && check_dst(home, ums, a);
}
 
int main() {
 
    int h, r;
 
    while(cin >> h >> r, h || r) {
 
        int u, m, s;
        double du, dm, ds;
        vector<point> homes, ums;
 
        for(int i = 0; i < h; ++i) {
            double x, y;
            cin >> x >> y;
            homes.push_back((point){ x, y, 0 });
        }
 
        cin >> u >> m >> s;
        cin >> du >> dm >> ds;
 
        for(int i = 0; i < u + m + s; ++i) {
            double x, y;
            cin >> x >> y;
            if(i < u) {
                ums.push_back((point){ x, y, du });
            } else if(u <= i && i < u + m) {
                ums.push_back((point){ x, y, dm });
            } else {
                ums.push_back((point){ x, y, ds });
            }
        }
 
        for(int i = 0; i < r; ++i) {
            double w, a;
            cin >> w >> a;
            for(int j = 0; j < homes.size(); ++j) {
                bool is_perfect = check_reach(homes[j], (point){ 0, 0, du }, w, a);
                for(int k = 0; k < ums.size(); ++k) {
                    if(check_reach(homes[j], ums[k], w, a)) {
                        is_perfect = false;
                    }
                }
                homes[j].d += is_perfect;
            }
        }
 
        int max_day = 0;
        for(int i = 0; i < homes.size(); ++i) {
            max_day = max(max_day, homes[i].d);
        }
 
        if(max_day) {
            bool is_out = false;
            for(int i = 0; i < homes.size(); ++i) {
                if(homes[i].d == max_day) {
                    if(is_out) cout << " " << i + 1;
                    else cout << i + 1;
                    is_out = true;
                }
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
 
    }
 
}

Measured memory_bytes: 3468
import sys
n = int(input())
ss =[]
for _ in range(n):
    ss.append(input())
cnt_p = []
cnt_m = []
for i in range(n):
    left = 0
    right = 0
    for s in ss[i]:
        if(s == '('):
            left += 1
        elif(s == ')'):
            if(left > 0):
                left -= 1
            else:
                right += 1
    if(left-right > 0):
        cnt_p.append((right,left))
    else:
        cnt_m.append((right,left))
 
 
cnt_p = sorted(cnt_p, key=lambda x: (x[0]))
cnt_m = sorted(cnt_m, key=lambda x: (x[1]*-1))
cnt = cnt_p + cnt_m
num = 0
for right,left in cnt:
    num -= right
    if(num < 0):
        print('No')
        sys.exit()
    num += left
if(num==0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 230108
from collections import deque
S = deque(input())
N = int(input())
is_inversed = False
for i in range(N):
    Q = input()
    if Q[0] == '1':
        is_inversed = not (is_inversed)
    else:
        if (Q[2] == '1' and is_inversed) or (Q[2] == '2' and not (is_inversed)):
            S.append(Q[4])
        else:
            S.appendleft(Q[4])
if is_inversed:
    print(''.join(list(S)[::-1]))
else:
    print(''.join(S))

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i64 A=read(),B=read(),C=read(),K=read(),Sum=0;
    if(K) Sum+=Min(K,A),K-=Min(K,A);
    K-=Min(K,B);
    Sum-=Min(K,C);
    print(Sum);
    output();
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#define bitpar __builtin_parity
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
int main()
{
	int n, m; cin>>n>>m;
	int a[16];
	for(int i=0; i<m; i++) cin>>a[i];
	ll f[100000];
	f[0]=1;
	for(ll i=1; i<=(1ll<<n); i++) f[i]=f[i-1]*i%MOD;
	if(m==0){
		cout<<f[1<<n]<<endl;
		return 0;
	}
	ll invf[100000];
	invf[1<<n]=inv(f[1<<n]);
	for(ll i=(1ll<<n)-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
	ll dp[16][1<<16]={};
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			int x=(1<<n)-a[i], y=(1<<j)-1;
			if(x>=y) dp[i][1<<j]=f[x]*invf[x-y]%MOD*(1ll<<j)%MOD;
		}
	}
	for(int i=m-2; i>=0; i--){
		for(int j=0; j<(1<<n); j++){
			dp[i][j]+=dp[i+1][j];
			dp[i][j]%=MOD;
			for(int d=0; d<n; d++){
				if((j&(1<<d))==0) continue;
				int j1=j^(1<<d);
				int x=(1<<n)-a[i]-j1, y=(1<<d)-1;
				if(x<y) continue;
				dp[i][j]+=dp[i+1][j1]*f[x]%MOD*invf[x-y]%MOD*(1ll<<d)%MOD;
				dp[i][j]%=MOD;
			}
		}
	}
	ll ans=f[1<<n];
	for(int k=0; k<(1<<n); k++){
		if(bitpar(k)){
			ans-=dp[0][k]*(1ll<<n)%MOD*f[(1<<n)-k-1]%MOD;
			ans=(ans+MOD)%MOD;
		}else{
			ans+=dp[0][k]*(1ll<<n)%MOD*f[(1<<n)-k-1]%MOD;
			ans%=MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

struct edge{
    int to,cost;
    edge(int to,int cost):to(to),cost(cost){}
};

const int SIZE=100000;
const int INF=1001001001001001001ll;
int N,M;
vector<edge>G[SIZE];
int dist_s[SIZE],dist_g[SIZE];

void dijkstra(int s,int *dist){
    fill_n(dist,N,INF);
    dist[s]=0;
    priority_queue<pint,vector<pint>,greater<pint>>que;
    que.push(pint(0,s));
    while(que.size()){
        int v,c;
        tie(c,v)=que.top();
        que.pop();
        if(dist[v]<c)continue;
        for(auto &e:G[v]){
            if(dist[e.to]<=c+e.cost)continue;
            dist[e.to]=c+e.cost;
            que.push(pint(dist[e.to],e.to));
        }
    }
}

vint bit[SIZE+1];
void bit_init(vpint &vec){
    rep(i,N){
        for(int k=i+1;k<=N;k+=k&-k)bit[k].pb(vec[i].se);
    }
    rep(i,N)sort(all(bit[i+1]));
}
int get(int k,int x){
    int ret=0;
    for(;k;k-=k&-k)ret+=bit[k].size()-(lower_bound(all(bit[k]),x)-bit[k].begin());
    return ret;
}

signed main(){
    scanf("%lld%lld",&N,&M);
    rep(i,M){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        G[a].pb(edge(b,c));
        G[b].pb(edge(a,c));
    }

    dijkstra(0,dist_s);
    dijkstra(N-1,dist_g);
    vpint vec;
    rep(i,N)vec.pb(pint(dist_s[i],dist_g[i]));
    sort(all(vec));
    bit_init(vec);

    int Q;scanf("%lld",&Q);
    while(Q--){
        int a,b;
        scanf("%lld%lld",&a,&b);
        int idx=lower_bound(all(vec),pint(a,INF))-vec.begin();
        printf("%lld\n",get(idx,b));
    }
    return 0;
}

Measured memory_bytes: 24768
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define pb push_back
#define pll pair<long long int, long long int>
#define great (long long int)(1e9+7)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fst first
#define scd second

void solve()
{
  ll n;
  cin>>n;
  ll a[n+6];
  ll dp[n+2];
  memset(dp,0,sizeof(dp));
  for(ll i=1;i<=n;i++)
  {
      cin>>a[i];
  }
  dp[1]=0;
  dp[2]=abs(a[2]-a[1]);
  //dp[3]=min(abs(a[3]-a[2]),abs(a[3]-a[1]));
  for(ll i=3;i<=n;i++)
  {
      dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
  }
  cout<<dp[n]<<"\n";
}

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define rep(i,x) for(int i=0;i<(x);++i)

const ll inf = 3e18;

struct edge {
	int to, cost;
	edge(int to, int cost) : to(to), cost(cost) {}
};

int N, M, C;

ll d[100000];
vector<edge> G[100000];
map<ll, vector<int> >  m;
bool found[100000];
map<int, bool> used[100000];

void dijkstra(int s)
{
	priority_queue<pii, vector<pii>, greater<pii> > q;
	fill(d, d + N, inf);
	d[s] = 0;
	q.push(pii(0, s));
	while (q.size()) {
		pii p = q.top(); q.pop();
		int v = p.scd;
		if (d[v] < p.fst) continue;
		rep(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				m[d[e.to]].PB(e.to);
				q.push(pii(d[e.to], e.to));
			}
		}
	}
}

signed main()
{
	scanf("%d %d %d", &N, &M, &C);

	ll sum = 0;

	rep(i, M) {
		int A, B, D; scanf("%d %d %d", &A, &B, &D), A--, B--;
		G[A].PB(edge(B, D));
		G[B].PB(edge(A, D));
		sum += D;
	}

	dijkstra(0);
	found[0] = true;

	ll mi = inf;

	m[0] = vector<int>();

	for (map<ll, vector<int> >::iterator itr = m.begin(); itr != m.end(); ++itr) {
		ll X = itr->fst;
		vector<int> vs = itr->scd;

		rep(i, vs.size()) found[vs[i]] = true;

		rep(i, vs.size()) {
			int v = vs[i];
			rep(j, G[v].size()) {
				edge e = G[v][j];
				if (!found[e.to]) continue;
				if (used[v][e.to]) continue;
				used[v][e.to] = used[e.to][v] = true;
				sum -= e.cost;
			}
		}

		mi = min(mi, sum + C * X);
	}

	printf("%lld\n", mi);
}

Measured memory_bytes: 43404
#include <stdio.h>

int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(0<=(x-r)&&(x+r)<=W){
   if(0<=(y-r)&&(y+r)<=H){
      printf("Yes\n");
   }else{
      printf("No\n");
   }
}else{
   printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}



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

	vector<ll> colors;//colors[i]:色iを使った最大のAを格納
	for(int i=0; i<N; i++){
		// これだとTLEになるので 2分探索しないとダメ
		// bool is_same_color = false;
		// for(int j=0; j<(int)colors.size(); j++){
		// 	if(colors[j] < A[i]){
		// 		colors[j] = A[i];
		// 		is_same_color = true;
		// 		break;
		// 	}
		// }
		// if(is_same_color == false) colors.push_back(A[i]);

		//2分探索
		int l_index=-1, r_index = (int)colors.size();
		while(r_index - l_index > 1){
			int mid = (l_index+r_index)/2;
			if(colors[mid] >= A[i]) l_index = mid;
			else r_index = mid;
		}
		if(r_index == colors.size()) colors.push_back(A[i]);
		else colors[r_index] = A[i];
	
	}
	cout << (int)colors.size() << endl;
	return 0;
}



Measured memory_bytes: 5016
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    int len =S.size();
    for(int i=0;i<len;++i){
        S[i] += N;
        if(S[i]>90){
            S[i] -=26;
        }
    }
    cout<<S<<endl;
    
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int maxN = 1e5 + 5;
int dp[maxN];
int h[maxN];

signed main() {
  int n = read();
  FOR(i, 1, n + 1) { h[i] = read(); }
  dp[2] = abs(h[1] - h[2]);
  FOR(i, 3, n + 1) {
    int jump1 = dp[i - 1] + abs(h[i - 1] - h[i]);
    int jump2 = dp[i - 2] + abs(h[i - 2] - h[i]);
    dp[i] = min(jump1, jump2);
  }
  print(dp[n]);
}


Measured memory_bytes: 1792