akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    int h, w;
    cin >> h;
    cin >> w;
    vector<vector<char>> c(h+2,vector<char>(w+2));
    rep(i, h+2) {
        rep(j, w+2) {
            if (i == 0 || j == 0 || i == h+1 || j == w+1) {
                c[i][j] == '.';
            } else {
                cin >> c[i][j];
            }
        }
    }
    bool flag = true;
    rep(i, h+1) {
        rep(j, w+1) {
            if (i == 0 || j == 0) continue;
            if (c[i][j] == '#') {
                if (c[i-1][j] == '.' && c[i+1][j] == '.' && c[i][j-1] == '.' && c[i][j+1] == '.') {
                    flag = false;
                    break;
                }
            }
        }
        if (!flag) break;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL A, B;

int main() {
    cin >> A >> B;
    LL C = __gcd(A, B);
    int ans = 0;
    for(int i = 2; (LL)i * i <= C; i++)
        if (C % i == 0) {
            ans++;
            while (C % i == 0) C /= i;
        }
    if (C > 1) ans++;
    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    bool zero = false;
    rep(i,n){
        cin >> a[i];
        if(a[i]==0) zero = true;
    }
    if(zero){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i,n){
        if(a[i] > LINF/ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,m;
    cin>>n>>m;
    vector<ll> h(n);
    vector<ll> ma(n);
    rep(i,0,n)cin>>h[i];
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        ma[a]=max(ma[a],h[b]);
        ma[b]=max(ma[b],h[a]);
    }
    int ans=0;
    rep(i,0,n){
        ans+=h[i]>ma[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4800
N, x = map(int, raw_input().split())
a = map(int, raw_input().split())

ans = 0

if a[0] > x:
    ans += (a[0]-x)
    a[0] = x
for i in xrange(len(a)-1):
    if sum(a[i:i+2]) > x:
        ans += (sum(a[i:i+2]) - x)
        a[i+1] -= (sum(a[i:i+2]) - x)

print ans

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

int main(){
  int n; cin>>n;
  vector<int> a(n+2,0);
  long long sum=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n+1]-a[n]);
  for(int i=1;i<=n;i++){
    long long ans=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
    cout<<ans<<endl;
  }
}

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

using namespace std;

long long solve(int n, int m, vector<long long> a, vector<long long> b, vector<long long> c, int sa, int sb, int sc) {
  vector<long long> dp(m + 1, -1e18);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      dp[j + 1] = max(dp[j + 1], dp[j] + a[i]*sa + b[i]*sb + c[i]*sc);
    }
  }
  return dp[m];
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  long long ans = -1e18;
  ans = max(ans, solve(n, m, a, b, c, 1, 1, 1));
  ans = max(ans, solve(n, m, a, b, c, -1, 1, 1));
  ans = max(ans, solve(n, m, a, b, c, 1, -1, 1));
  ans = max(ans, solve(n, m, a, b, c, -1, -1, 1));
  ans = max(ans, solve(n, m, a, b, c, 1, 1, -1));
  ans = max(ans, solve(n, m, a, b, c, -1, 1, -1));
  ans = max(ans, solve(n, m, a, b, c, 1, -1, -1));
  ans = max(ans, solve(n, m, a, b, c, -1, -1, -1));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

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

#define RANGE(a,i,b) ((a)<=(i)&&(i)<(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

int d[92][92];
int field_[92][92];



vector<PII> starts[4];
int field [92][92];
int M,N;

int max_depth=0;

//int dp[92][92][10000];

void solve(int x, int y, int broken){
    //cerr<<x<<" "<<y<<endl;
    field[x][y]=0;
    bool b=false;
    rep(i,4){
        int xx=x+dx[i];
        int yy=y+dy[i];
        if(field[xx][yy]==1){
            b=true;
            solve(xx,yy,broken+1);
        }
    }
    field[x][y]=1;
    if(!b)max_depth=max(max_depth,broken+1);
}

int main(void){
    //rep(i,4)starts[i].clear();
    while(cin>>M>>N,M||N){
    max_depth=0;
    rep(i,M)rep(j,N){
        int t;
        cin>>t;
        field[i+1][j+1]=t;
    }
    rep(i,M)rep(j,N){
        if(field[i][j]==1)solve(i,j,0);
    }
    cout<<max_depth<<endl;
    }
    return 0;
}


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

int main(){
  int X,Y;
  cin >> X >> Y;
  string ans = "No";
  for (int i=0;i<=Y/2;i++){
    if( 2*i + 4*(X-i) == Y) ans = "Yes";
//    cout << i << endl;
  }
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 3532
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string s;
unsigned long long Q;

int main(){
  cin >> s >> Q;

  bool rev_flg = false;

  for(int i=0; i<Q; ++i){
    int T;
    cin >> T;
    if(T == 1){
      rev_flg = !rev_flg;
    }
    else{
      int F;
      string C;
      cin >> F >> C;
      if(F == 2 && rev_flg == false || F == 1 && rev_flg == true){
        s += C;
      }
      else{
        s.insert(0,C);
      }
    }
  }
  
  if(!rev_flg){
    cout << s << endl;
  }
  else{
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,k;
    cin>>n>>k;
    lli i,a[n],sum=0;
    
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    
    for(i=0;i<k;i++) sum+=a[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3636
h,w = map(int, input().split())
maze = [input() for i in range(h)]
route = [[0] * w for i in range(h)]
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            white += 1
 
 
class MyStack:
    def __init__(self):
        self.stack = []
    def push(self, item_1, item_2):
        self.stack.append([item_1,item_2])
    def pop(self):
        result = self.stack.pop(0)
        return result[0],result[1]
 
 
def min_route():
    global h,w
    stack = MyStack()
    stack.push(1,1)
    route[0][0] = 0
    while len(stack.stack) >= 1:
        y,x = stack.pop()
        route_num = route[y-1][x-1] + 1
        if y != h:
            if maze[y][x-1] == '.' and route[y][x-1] == 0:
                stack.push(y+1,x)
                route[y][x-1] += route_num
        if y != 1:
            if maze[y-2][x-1] == '.' and route[y-2][x-1] == 0:
                stack.push(y-1,x)
                route[y-2][x-1] += route_num
        if x != w:
            if maze[y-1][x] == '.' and route[y-1][x] == 0:
                stack.push(y,x+1)
                route[y-1][x] += route_num
        if x != 1:
            if maze[y-1][x-2] == '.' and route[y-1][x-2] == 0:
                stack.push(y,x-1)
                route[y-1][x-2] += route_num
        if route[h-1][w-1]  != 0:
            return route[h-1][w-1]
    print(-1)
    exit()
 
ans = white - min_route() - 1
 
if ans < 0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 3188
/*input
4 4
..##
#...
###.
###.
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w; cin >> h >> w;
    vector<vector<bool>> grid(h, vector<bool> (w));
    vector<vector<ll>> dp(h, vector<ll> (w, INF64));
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++)
    {
    	char c; cin >> c;
    	if(c == '#') grid[i][j] = 1;
    }
    dp[0][0] = grid[0][0];
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++)
    {
    	if(i)
    	{
    		int c = (grid[i][j] && (grid[i][j] != grid[i - 1][j]));
    		dp[i][j] = min(dp[i][j], dp[i - 1][j] + c);
    	}
    	if(j)
    	{
    		int c = (grid[i][j] && (grid[i][j] != grid[i][j - 1]));
    		dp[i][j] = min(dp[i][j], dp[i][j - 1] + c);
       	}
    }
    cout << dp[h - 1][w - 1];

    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int A;
    static HashSet<string> S = new HashSet<string>();
    static void INPUT()
    {
        A = NextInt();
        for (var i = 0; i < A; i++)
            S.Add(NextString());
    }
    static void OUT()
    {
        Console.WriteLine(S.Count());
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




Measured memory_bytes: 43592
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
int val[100010];
 
signed main(){
	int N,M;
	cin >> N >> M;
	for(int i = 0 ; i < N ; i++) cin >> val[i];
	map<int,int> seg;
	for(int i = 0 ; i < N ; i++) seg[i] = i;	
	priority_queue< pair<int,pair<int,int>>> Q;
	for(int i = 0 ; i+1 < N ; i++)
		Q.push({val[i]+val[i+1],{i,i+1}});
	vector<int> res;
	int cnt = 0;
	while(Q.size()){
		auto q = Q.top(); Q.pop();
		if( q.first < M ) continue;
		int a = q.second.first;
		int b = q.second.second;
		if( val[a] + val[b] != q.first ) continue;
		res.push_back(seg[a]);
		//cout << a << " " << b << " "  << "|" << seg[a] << " " << val[a] + val[b] << endl;
		int v =  val[a] + val[b];;
		val[a] = v;
		val[seg[b]] = v;		
		seg[a] = seg[b];
		seg.erase(b);
		auto it1 = seg.lower_bound(a);
		auto it2 = seg.upper_bound(seg[a]);
 
		if( it1 != seg.begin() ) {
			--it1;
			int x = it1->second;
			int y = a;
			Q.push({val[x]+val[y],{x,y}});
		}
		if( it2 != seg.end() ){
			int x = seg[b];
			int y = it2->first;
			Q.push({val[x]+val[y],{x,y}});
		}
		
	}
	if( res.size() != N-1 ){
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	reverse(res.begin(),res.end());
	for( auto p : res) cout << p+1 << endl;
}

Measured memory_bytes: 13936
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

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

    while(N > 0){
        if(N % 4 == 0){
            cout << "Yes" << "\n";
            return 0;
        }
        N -= 7;
    }
    if(N == 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool cond = abs(a-c)<=d
  || (abs(a-b)<=d&&abs(b-c)<=d);
  cout << (cond ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
class Fibonacci(object):
    memo = [1, 1]

    def get_nth(self, n):
        if n < len(Fibonacci.memo):
            return Fibonacci.memo[n]
        # print('fib({0}) not found'.format(n))
        for i in range(len(Fibonacci.memo), n+1):
            result = Fibonacci.memo[i-1] + Fibonacci.memo[i-2]
            Fibonacci.memo.append(result)
            # print('fib({0})={1} append'.format(i, result))
        return Fibonacci.memo[n]


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())

    # ?????£??????????????°????¨????
    f = Fibonacci()
    result = f.get_nth(num)

    # ???????????????
    print('{0}'.format(result))

Measured memory_bytes: 7712
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<climits>
#include<algorithm>
using namespace std;
const int maxn = 200010;
int val[maxn];
int tot;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",val + i);
    }
    int maxv = INT_MIN;
    int minv = val[0];
    for(int i = 1;i < n;i++){
        maxv = max(maxv,val[i] - minv);
        minv = min(minv,val[i]);
    }
    printf("%d\n",maxv);
    return  0;
}



Measured memory_bytes: 3988
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long A = Long.parseLong(sc.next());
    long B = Long.parseLong(sc.next());
    long C = Long.parseLong(sc.next());
    long D = Long.parseLong(sc.next());
    long K = lcm(C, D);
    
    long a = B/C;
    long b = (A-1)/C;
    long ab = a-b;
    
    long c = B/D;
    long d = (A-1)/D;
    long cd = c-d;
    
    long e = B/K;
    long f = (A-1)/K;
    long ef = e-f;
    
    long g = ab+cd-ef;
    long ans = B-A-g+1;
      
    System.out.println(ans);
  }
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
      if(n == 0) return m;
        return gcd(n, m % n);
  } 
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
  }
}

Measured memory_bytes: 21844
#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() {
  string S;
  cin >> S;
  bool ans = true;

  int n = S.size();
  rep(i, (n - 1) / 2) {
    if(S[i] != S[n - i - 1]) {
      ans = false;
      break;
    }
  }

  if (ans) {
    rep(i, (n - 1) / 2) {
      if(i != (n - 1) / 2 - i - 1 && S[i] != S[(n - 1) / 2 - i - 1]) {
        // cout << 'a' << i << endl;
        ans = false;
        break;
      }
      if((n + 1) / 2 + i != n - i - 1 && S[(n + 1) / 2 + i] != S[n - i - 1]) {
        // cout << 'b' << i << endl;
        ans = false;
        break;
      }
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
map<string,int>q;
int n;
string a;
LL A;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        sort(a.begin(),a.end());
        A+=q[a]++;
    }
    cout<<A<<'\n';
    return 0;
}

Measured memory_bytes: 11264
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, q = read_line(int, int)
s, = read_line(str)

m = [0 for _ in range(len(s) + 1)]

c = 0
for i in range(len(s)):
    if s[i:i+2] == 'AC':
        c += 1
    m[i + 1] = c

for i in range(q):
    l, r = read_line(int, int)

    if c == 0:
        print(0)
        continue
    print(m[r - 1] - m[l - 1])


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

int cost(pair<int, int> t, pair<int, int> t2)
{
    return (abs(t.first - t2.first) + abs(t.second - t2.second));
}

signed main()
{
    int h, w, d, q;
    map<int, pair<int, int>> m;
    vector<pair<int, int>> v;
    cin >> h >> w >> d;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            int tmp;
            cin >> tmp;
            m[tmp] = make_pair(j, i);
        }
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int tl, tr;
        cin >> tl >> tr;
        v.push_back(make_pair(tl, tr));
    }

    vector<vector<int>> sum;
    for (int j = 1; j <= d; j++)
    {
        vector<int> tmp;
        tmp.push_back(0);
        pair<int, int> current = m[j];
        for (int i = j + d; i <= h * w; i += d)
        {
            tmp.push_back(tmp[tmp.size() - 1] + cost(current, m[i]));
            current = m[i];
        }
        sum.push_back(tmp);
    }

    bool f = false;
    if (f)
    {
        for (int i = 0; i < sum.size(); i++)
        {
            for (int j = 0; j < sum[i].size(); j++)
            {
                cout << sum[i][j] << " ";
            }
            cout << endl;
        }
    }
    for (int i = 0; i < q; i++)
    {
        if (f)
            cout << (v[i].second - 1) / d << "," << sum[(v[i].first - 1) % d][(v[i].second - 1) / d] << " " << (v[i].first - 1) / d << "," << sum[(v[i].first - 1) % d][(v[i].first - 1) / d] << endl;
        cout << sum[(v[i].first - 1) % d][(v[i].second - 1) / d] - sum[(v[i].first - 1) % d][(v[i].first - 1) / d] << endl;
    }
}

Measured memory_bytes: 13936
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;
  int n = sz(s);
  rep(i,n){
    if (i%2==0){
      if (s[i]=='L'){
        cout << "No" << endl;
        return 0;
      }
    }
    if (i%2==1){
      if (s[i]=='R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let x: usize = sc.read();
    let y: usize = sc.read();
    let mut ans = 0;
    if x == 1 {
        ans += 300000;
    }
    if x == 2 {
        ans += 200000;
    }
    if x == 3 {
        ans += 100000;
    }
    if y == 1 {
        ans += 300000;
    }
    if y == 2 {
        ans += 200000;
    }
    if y == 3 {
        ans += 100000;
    }
    if x == 1 && y == 1 {
        ans += 400000;
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write(&mut self, s: String) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
vector<pair<ll, pair<ll, ll>>> vec;

//解法
void solve() {
	
	bool flag = true;

	rep(i, N) {
		ll len = vec[i].second.first + vec[i].second.second - vec[i + 1].second.first - vec[i + 1].second.second;
		len = abs(len);
		ll time = vec[i + 1].first - vec[i].first;

		if (len <= time
			&& (time - len) % 2 == 0) {
		}
		else {
			flag = false;
		}
	}

	cout << (flag ? "Yes" : "No");

	return;
}

int main() {

	//入力
	cin >> N;
	vec.resize(N+1);

	vec[0].first = 0;
	vec[0].second.first = 0;
	vec[0].second.second = 0;

	rep(i, N) cin >> vec[i+1].first >> vec[i+1].second.first >> vec[i+1].second.second;

	solve();
	cout << endl;
	return 0;
}

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


void displayVector(vector<int> v)
{
	int n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,x,mi,ans,dlt,now;
void in(){scanf("%d",&n);}
void ac()
{
	for(int i=1;i<=n;++i)
	{
		dlt=0;
		scanf("%d",&x);
		mi=(int)log2(x);
		if(x!=(1<<mi))dlt=1;
		if(now<mi)ans+=mi-now,now=mi;
		if(now>mi)now=mi,dlt=0;
		if(dlt)++ans,++now;
	}
	printf("%d",ans);
}
int main(){in();ac();}

Measured memory_bytes: 256
import math

n = int(input())
l = list(map(int,input().split()))
y = sum(l)
x = y//n
x1 = math.ceil(y/n)
sum1 = 0
sum2 = 0
for i in l:
  sum1 += (i-x)**2
  sum2 += (i-x1)**2
print(min(sum1,sum2))

Measured memory_bytes: 3064
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nm=arr.shift().split(" ").map(Number);
var n=nm[0];
var m=nm[1];
var all=[];
var loop=function (start,ary){
   if(ary.length==m)all.push(ary);
   else{
      for(var i=start;i<n;i++)loop(i+1,ary.concat(i));
   }
};
loop(0,[]);
var ab=[];
while(n--)ab.push(arr.shift().split(" ").map(Number));
var max=0;
all.forEach(function(v){
   var sum=0;
   while(true){
      if(v.length<=1)break;
      var a=v.shift();
      v.forEach(function(value){
         sum+=(ab[a][0]-ab[value][0])*(ab[a][0]-ab[value][0]);
         sum+=(ab[a][1]-ab[value][1])*(ab[a][1]-ab[value][1]);
         sum+=(ab[a][2]-ab[value][2])*(ab[a][2]-ab[value][2]);
      });
   }
   max=Math.max(max,sum);
});
console.log(max.toFixed(6));

Measured memory_bytes: 78640
#include <iostream>
#include <string>
using namespace std;
int main(void){
   int a,x,ans = 0;
   while(true){
       cin >> a >> x;
       if(a == 0 and x == 0){
           break;
       } else {
           for(int i = 1; i <= a - 2; i++){
               for(int j = i + 1; j <= a - 1; j++){
                   for(int k = j + 1; k <= a; k++){
                       if(i + j + k == x){
                           ans++;
                       }
                   }
               }
           }
       }
       cout << ans << endl;
       ans = 0;
   }
    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int C, R;
int d[11111][11];
int to[11111];
int t[11111];

inline int bitcount(int n)
{
  n = (n & 0x55555555) + (n >> 1 & 0x55555555);
  n = (n & 0x33333333) + (n >> 2 & 0x33333333);
  n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f);
  n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff);
  return (n & 0x0000ffff) + (n >> 16 & 0x0000ffff);
}

inline int bitcount(ll n)
{
  n = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
  n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333);
  n = (n & 0x0f0f0f0f0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f0f0f0f0f);
  n = (n & 0x00ff00ff00ff00ff) + ((n >> 8) & 0x00ff00ff00ff00ff);
  n = (n & 0x0000ffff0000ffff) + ((n >> 16) & 0x0000ffff0000ffff);
  return (int)((n & 0x00000000ffffffff) + ((n >> 32) & 0x00000000ffffffff));
}

int main()
{
  while(cin >> R >> C, R){
    rep(i, R) rep(j, C) cin >> d[j][i];

    rep(i, C) to[i] = 0;
    rep(i, C) rep(j, R) to[i] |= d[i][j] * (1 << j);

    int res = 0;
    rep(i, 1 << R){
      rep(j, C) t[j] = to[j];
      rep(j, C) t[j] = i & ~t[j] | ~i & t[j];
      int sum = 0;
      rep(j, C) sum += max(bitcount(t[j]), R - bitcount(t[j]));
      maxup(res, sum);
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1672
N = gets.to_i
h = {}
1.upto(1.0/0){|i|
  edge = i * (i - 1) / 2
  h[edge] = i
  break if edge > 10**5
}

if !h[N]
  puts:No
  exit
end

vortex = h[N]
edges = vortex.times.map{[]}
n = 1
vortex.times{|i|
  i.times{|j|
    edges[i] << n
    edges[j] << n
    n += 1
  }
}
puts:Yes
p vortex
edges.each{|e|
  puts [e.size, *e]* " "
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<vector<ll>> a(N,vector<ll>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin >> a.at(i).at(j);
    }
  }

  vector<ll> group(1<<N);
  for(int bit=0;bit<(1<<N);bit++){
    bitset<16> S(bit);
    ll tmp=0;
    for(int i=0;i<N;i++){
      if(!S.test(i))  continue;
      for(int j=i;j<N;j++){
        if(!S.test(j))  continue;
        tmp+=a.at(i).at(j);
      }
    }
    group.at(bit)=tmp;
  }

  vector<ll> dp((1<<N),1e-15);
  dp.at(0)=0;
  for(int bit=0;bit<(1<<N);bit++){
    for(int g=bit;g>0;g=(g-1)&bit){
      dp.at(bit)=max(dp.at(bit),dp.at(bit-g)+group.at(g));
    }
  }
  cout << dp.at((1<<N)-1) << endl;

  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  const int MOD = 1000000007;
  int n,w;
  cin>>n>>w;
  vector<int> v(n);
  REP(i,n)cin>>v[i];
  sort(begin(v),end(v));
  int sum=0;
  REP(i,n){
    int rem = w;
    REP(j,i)rem-=v[j];
    if (rem < 0) break;
    vector<int> dp(10001);
    dp[0] = 1;
    for(int j=i+1;j<n;++j){
      vector<int> tmp(rem+1);
      REP(k,rem+1){
        tmp[k] = dp[k];
        if(k >= v[j]) {
          tmp[k] += dp[k-v[j]];
          tmp[k] %= MOD;
        }
      }
      dp.swap(tmp);
    }
    for (int j=max(rem-v[i]+1,0);j<=rem;++j){
      sum += dp[j];
      sum %= MOD;
    }
  }
  if (accumulate(begin(v),end(v),0) <= w) ++sum;
  sum %= MOD;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,k;
int a[110];
bool bio[100010];
bool dp[100010];

bool resi(int k)
{
	if(k<a[0])
		return false;
	
	if(bio[k])
		return dp[k];
		
	bio[k]=true;
	
	for(int i=0;i<n;i++)
		if(a[i]<=k && resi(k-a[i])==false)
		{
			dp[k]=true;
			return true;
		}
		
	dp[k]=false;
	return false;
}

int main()
{
	ios::sync_with_stdio(false);	
	cin.tie(0);
	
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	if(resi(k))
		cout<<"First";
	else
		cout<<"Second";
	
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

struct FenwickTree {
    int length;
    vector<ll> node;
    FenwickTree (ll N) : length(N), node(length + 1, 0) {}
    void add(int idx, ll val) {
        ++idx;
        while (idx <= length) {
            node[idx] += val;
            idx += (idx & (-idx));
        }
    }
    ll getsum(int idx) {
        ll ans = 0;
        while (idx) {
            ans += node[idx];
            idx -= (idx & (-idx));
        }
        return ans;
    }
};

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    int left = 0;
    int right = 1001001001;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        vector<int> sum(n + 1, 0);
        REP(i, n) {
            if (a[i] < mid) sum[i + 1] = sum[i] - 1;
            else sum[i + 1] = sum[i] + 1;
        }
        vector<pair<int, int>> S(n + 1);
        REP(i, n + 1) S[i] = {sum[i], i};
        sort(ALL(S));
        vector<int> s(n + 1, 0);
        REP(i, n) {
            if (S[i].first == S[i + 1].first) s[S[i + 1].second] = s[S[i].second];
            else s[S[i + 1].second] = s[S[i].second] + 1;
        }
        FenwickTree ft(n + 1);
        ll cnt = 0;
        REP(i, n + 1) {
            cnt += ft.getsum(s[i] + 1);
            ft.add(s[i], 1);
        }
        if ((n * (n + 1) / 2 + 1) / 2 <= cnt) left = mid;
        else right = mid;
    }
    cout << left << "\n";
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    ll total = 0;
    int mi = 1001001001;
    bool check = false;
    int m = 0;
    rep(i, N){
        cin >> A[i];
        total += abs(A[i]);
        mi = min(mi, abs(A[i]));
        if(A[i] < 0) m++;
        if (A[i] == 0) check = true;
    }

    if(check || m%2 == 0){
        cout << total << endl;
    } else {
        cout << total - 2 * mi << endl;
    }

    return 0;
}

Measured memory_bytes: 640
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nok(a, b):
    m = a * b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a + b)    


def main():
    mod = 1e9 + 7
    n, m = rinput()
    s = rlinput()
    t = rlinput()
    a = [1] * (m + 1)
    for j in s:
        d = a[:]
        k = 0
        for i, v in enumerate(t):
            d[i] = (k + d[i]) % mod
            if j == v:
                k = (k + a[i]) % mod
        d[-1] = (k + d[-1]) % mod
        a = d[:]
    print(int(a[-1]))
    
    
    
main()

Measured memory_bytes: 3316
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.insert(0, 10**6)
b.insert(0, 10**6)
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)

for n in xyc:
    ans = min(ans, a[n[0]] + b[n[1]] - n[2])

print(ans)

Measured memory_bytes: 38728
import sys
my_str = input()

for i in range(len(my_str)):
    if "a" <= my_str[i] <= "z":
        sys.stdout.write(my_str[i].upper())
    elif "A" <= my_str[i] <= "Z":
        sys.stdout.write(my_str[i].lower())
    else:
        sys.stdout.write(my_str[i])
sys.stdout.write("\n")

Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  string s;std::cin >> s;
  set<ll> r, w;
  for(int i=0;i<n;i++) (s[i]=='W'?w:r).insert(i);
  ll ans = 0;

  while(true){
    ll max_r = (r.empty()?-1:(*--r.end()));
    ll min_w = (w.empty()?100000000:(*w.begin()));
    if(max_r<min_w) break;

    r.erase(max_r);
    w.erase(min_w);
    r.insert(min_w);
    w.insert(max_r);
    ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


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

#define MAX_N 8003

bool can(vector <int> v ,int x){
    bitset <MAX_N> bs; bs[0] = 1;
    int tot = 0;
    for(int&i : v)
        bs |= (bs<<i) ,tot += i;
    return !((tot+x)&1) && (tot >= x && bs[(tot-x)/2]);
}

int main()
{
    string s;
    int x ,y;
    cin >> s; s += 'T';
    cin >> x >> y; y = abs(y);

    vector <int> units[2];
    int axis = 0 ,mvs = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'T'){
            units[axis].push_back(mvs);
            axis ^= 1 ,mvs = 0;
        }
        else
            mvs++;
    }

    x = abs(x-units[0][0]);
    units[0].erase(units[0].begin());
    cout << (can(units[0] ,x) && can(units[1] ,y) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String str = in.next();
        char ch = str.charAt(0);
        

        if(isUpperCase(ch)==true)
        {
            System.out.println('A');
        }
        else
            {
                System.out.println('a');
            }
    }

}


Measured memory_bytes: 35516
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int AS = 500001;
char cn[AS], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
char * di = cn;
int dat[2 * AS];

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


	int N = 0;
	while ((ct = getchar_unlocked()) >= '0') N = N * 10 + ct - '0';
	fread(cn, 1, N + 1, stdin);
	auto da = dat + AS;
	rep(i, N) *da++ = (1 << *ci++ - 'a');
	da = dat + AS - 1;
	for (auto db = dat + AS * 2 - 1; da > dat; da--) *da = *db-- | *db--;

	ci = cn;
	fread(cn, 1, AS, stdin);
	int Q = getint();

	const char a[27] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6' };

	rep(j, Q) {
		char q = *ci++;
		ci++;
		if (q == '1') {
			int i = getint() - 1 + AS;
			for (dat[i] = 1 << *ci++ - 'a'; i > 1; i >>= 1) dat[i >> 1] = dat[i] | dat[i ^ 1];
			ci++;
		}
		else {
			int ret = 0;
			for (int l = getint() - 1 + AS, r = getint() + AS; l < r; l >>= 1, r >>= 1) {
				if (l & 1) ret |= dat[l++];
				if (r & 1) ret |= dat[--r];
			}
			int kotae = __builtin_popcount(ret);
			if (kotae >= 20) *di++ = '2';
			else if (kotae >= 10) *di++ = '1';
			*di++ = a[kotae];
			*di++ = '\n';
		}
	}
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4608
import sys
from operator import itemgetter

input = sys.stdin.readline

N, M = map(int, input().split())
C = [None] * N
for i in range(N):
    a, b = map(int, input().split())
    C[i] = [a, b]
C = sorted(C, key=itemgetter(0))

cnt, ans = 0, 0
for a, b in C:
    x = min(b, M - cnt)
    ans += a * x
    cnt += x
    if cnt == M:
        break
print(ans)


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

int N, Q;
string S;
vector<int> leftrange, rightrange;
vector<int> Leftsum;
vector<bool> ACmemo;

int main() {
    cin >> N >> Q >> S;
    ACmemo.resize(N);
    leftrange.resize(Q); rightrange.resize(Q); Leftsum.resize(N+1);
    for(int i = 0; i < Q; i++) scanf("%d %d", & leftrange[i], & rightrange[i]);


    for (int i = 0; i < N; i++) {
        if (S[i] == 'A') {
            ACmemo[i] = 1;
        }
        if(i != 0 && ACmemo[i-1] && S[i] != 'C') {
            ACmemo[i-1] = 0;
        }
    }

    Leftsum[0] = 0;
    for (int i = 1; i < N+1; i++) {
        Leftsum[i] += Leftsum[i-1];
        if (ACmemo[i-1]) Leftsum[i]++;
    }


    //printf("leftrange-1 %d rightrange %d ", leftrange[1]-1, rightrange[1]);
    //printf("%d %d\n", Rightsum[leftrange[1]-1], Rightsum[rightrange[1]-1]);
    for (int i = 0; i < Q; i++) {
        int ans = Leftsum[rightrange[i]-1] - Leftsum[leftrange[i]-1];
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-

a = [int(input()) for i in range(5)]

b = int(input())

c = 0
count = 0
# print(a, b)

for i in a:
    for j in a:
        c = j - i

        if c > b:
            count += 1

if count >= 1:
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 2940
r,c = map(int,input().split())
n = []
for i in range(r):
    n.append(list(map(int,input().split())))
    n[i].append(sum(n[i]))
n.append([])
for j in range(c):
    s = 0
    for k in range(r):
        s += n[k][j]
    n[r].append(s)
n[r].append(sum(n[r]))
for l in range(r+1):
    print(" ".join(list(map(str,n[l]))))


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

 
int main() {
    ll x,y;
    cin>>x>>y;
    ll a=x;//初項
    int count=0;
    while(1){
        if(a>y)break;
        count++;
        a=a*2;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int M=20,N=(1<<15)+10;
double g[M][M],dis[M];
int vis[M],n,x[M],y[M],a[M];
double dp[N];
double dist(double x,double y) { return sqrt(x*x+y*y); }
double solve(vector<PII> x) {
	int m=SZ(x);
	rep(i,0,m) rep(j,i+1,m) g[i][j]=g[j][i]=dist(x[i].fi-x[j].fi,x[i].se-x[j].se);
	rep(i,0,m) vis[i]=0;
	vis[0]=1; rep(i,1,m) dis[i]=g[0][i];
	double r=0;
	rep(i,0,m-1) {
		double pd=1e20; int pp=-1;
		rep(j,0,m) if (!vis[j]&&dis[j]<pd) {
			pd=dis[j]; pp=j;
		}
		vis[pp]=1; r+=pd; 
		rep(j,0,m) dis[j]=min(dis[j],g[pp][j]);
	}
	return r;
}
int main() {
	scanf("%d",&n);
	rep(i,0,n) scanf("%d%d%d",x+i,y+i,a+i);
	rep(S,1,(1<<n)) {
		vector<PII> v;
		rep(i,0,n) if (S&(1<<i)) {
			dp[S]+=a[i];
			v.pb(mp(x[i],y[i]));
		}
		dp[S]-=solve(v); dp[S]/=SZ(v);
	}
	rep(S,1,(1<<n)) {
		int nS=S;
		while (1) {
			dp[S]=max(dp[S],min(dp[nS],dp[S-nS]));
			if (nS==0) break;
			nS=(nS-1)&S;
		}
	}
	printf("%.10f\n",dp[(1<<n)-1]);
}


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

int main() {
  string s;
  string t;
  cin >> s >> t;
  int S = s.size(), T = t.size();

  bool ans = false;
  int v = -1;
  if (S < T) ans = false;
  else {
    for (int k = 0; k <= S-T; k++) {
      for (int i = 0; i < T; i++) {
        if (s[k+i] != t[i] && s[k+i] != '?') {
          ans = false;
          break;
        }
        ans = true;
      }
      if (ans) v = k;
    }
  }

  if (v == -1) cout << "UNRESTORABLE" <<endl;
  else {
    for (int i = 0; i < T; i++) s[v+i] = t[i];
    for (int i = 0; i < S; i++) {
      if (s[i] == '?') s[i] = 'a';
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 256
a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
    for bt in range(0,31-at):
        water = (at * a + bt * b) * 100
        if water > f:
            continue

        # 溶け残らないように砂糖を選ぶ
        maxsugar = water * e // 100
        for ct in range(0, (maxsugar)//c + 1):
            for dt in range(0, (maxsugar-ct*c+1)//d + 1):
                sugar = ct * c + dt * d

                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    # 水１００に対して溶けている砂糖の量
                    n = 100 * sugar / water
                    if n == e:
                        print(water + sugar, sugar)
                        exit()
                    if n > maxn:
                        ans = water + sugar, sugar
                        maxn = n
print(*ans)

Measured memory_bytes: 9152
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	int n;
	cin >> n;
	vector<vector<int>>d(n, vector<int>(2));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cin >> d[i][j];
		}
	}

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		if (d[i][0] == d[i][1])
		{
			ans += 1;
			if (ans >= 3)
			{
				cout << "Yes" << endl;
				break;
			}
		}
		if (d[i][0] != d[i][1])
		{
			ans = 0;
		}
	}

	if (ans < 3)
	{
		cout << "No" <<endl;
	}


}



Measured memory_bytes: 3632
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

struct zahyou {
    int d;
    vector<int> x;
    zahyou(int d) : d(d) {
        x.resize(d);
    }
    bool operator *(zahyou & a) {
        double ans = 0;
        rep(i, d) {
            ans += (a.x[i] - x[i]) * (a.x[i] - x[i]);
        }
        ans = sqrt(ans);
        return floor(ans) == ans;
    }
};

int main() {
    int n, d;
    cin >> n >> d;
    vector<zahyou> zahyous;
    rep(i, n) {
        zahyou tmp(d);
        rep(j,d) {
            cin >> tmp.x[j];
        }
        zahyous.push_back(tmp);
    }

    int ans = 0;
    rep(i,n) {
        for(int j = i + 1; j < n; ++j) {
            if(zahyous[i] * zahyous[j]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define N 100000

typedef struct{
  char name[10];
  int time;
} ps;


int main(){
  ps dat[N];
  int i,x,y,head=0,tail,t=0;

  scanf("%d%d",&x,&y);
  
  tail = x-1;
  
  for(i = 0; i < x; i++){
    scanf("%s%d",dat[i].name,&dat[i].time);
  }


  for(i = 0;; i++){

    if(i == N)i = head;
    dat[i].time -= y;

    if(dat[i].time > 0){
      tail++;
      if(tail == N)tail = 0;
      dat[tail] = dat[head];
      t += y;

    }

    else if(dat[i].time <= 0){
      t += y + dat[i].time;
      
      printf("%s %d\n",dat[i].name,t);

      if(head == tail)break;

    }

    head ++;

    if(head == N)head = 0;
    
  }

  return 0;
}



Measured memory_bytes: 3240