akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 2e6 + 10 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f;
}

ll n;

ll a[maxn];

multiset <ll> s, t;

signed main()
{
	scanf("%lld", &n);
	rep(i, 1, (1 << n))
	{
		ll tmp;
		scanf("%lld", &tmp);
		t.insert(-tmp);
	}
	ll now = *t.begin();
	s.insert(now);
	t.erase(t.begin());
	for(ll i = 1; i <= (1 << (n - 1)); i <<= 1)
	{
		// cout << "I : " << i << endl;
		ll tot = 0;
		for(int j : s)
		{
			// cout << "Now : " << j << endl;
			if(t.end() == t.upper_bound(j)) return puts("No"), 0;
			ll tmp = *t.upper_bound(j);
			// cout << tmp << endl;
			a[++tot] = tmp;
			t.erase(t.upper_bound(j));
		}
		rep(i, 1, tot) s.insert(a[i]);
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 13568
$str = gets
$sstr = $str.split("")

$count = 0
$last = $sstr.length - 2

for i in 0..$last
  for s in i+1..$last
    if $sstr[i] == $sstr[s]
      $count += 1
    end
  end
end

if $count > 0
  puts "no"
else puts "yes"
end

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

int main(){
    int H, W, N, M, cnt, WW, HH;
    cin >> W >> H >> N;
    vector<vector<bool>> block(W, vector<bool>(H));
    cnt = 0;
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            block.at(i).at(j) = false;
        }
    }

    for(int i = 0; i < N; i++){
        cin >> WW >> HH >> M;
        switch (M)
        {
        case 1:
            for(int i = 0; i < WW; i++){
                for(int j = 0; j < H; j++){
                    block.at(i).at(j) = true;
                }
            }
            break;
        case 2:
            for(int i = WW; i < W; i++){
                for(int j = 0; j < H; j++){
                    block.at(i).at(j) = true;
                }
            }
            break;
        case 3:
            for(int i = 0; i < W; i++){
                for(int j = 0; j < HH; j++){
                    block.at(i).at(j) = true;
                }
            }
            break;
        case 4:
            for(int i = 0; i < W; i++){
                for(int j = HH; j < H; j++){
                    block.at(i).at(j) = true;
                }
            }
            break;

        }
    }

    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(!block.at(i).at(j)){
                cnt++;
            }
        }
    }

    cout << cnt << endl;


}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        String t = in.next();
        
        out.println(s.length() + 1 == t.length() && t.startsWith(s) ? "Yes" : "No");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 25436
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n,m;
	cin>>n>>m;
	vvi in(n,vi(2));
	rep(i,n)cin>>in[i][0]>>in[i][1];
	sort(all(in));
	int s=0;
	rep(i,n){
		int c=min(m,in[i][1]);
		s+=c*in[i][0];
		m-=c;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 5760
// you should probably see at the bottom ..
#include<bits/stdc++.h>

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)
#define ff first
#define ss second

using namespace std;

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	map<pair<int, int>, int> val;
	vector<pair<int, int>> row(n + 1), col(m + 1);
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		row[a].ff++;
		col[b].ff++;
		val[ {a, b}]++;
	}

	for (int i = 1; i <= n; i++) row[i].ss = i;
	for (int i = 1; i <= m; i++) col[i].ss = i;
	sort(rrange(row)), sort(rrange(col));
	int ans = 0;
	int i = 0, j = 0;
	while (i < n and j < m) {
		int cur = row[i].ff + col[j].ff - val[ {row[i].ss, col[j].ss}];
		ans = max(ans, cur);
		int ans1 = 0, ans2 = 0;
		// dbg(i, j,cur);
		if (i + 1 < n) ans1 = row[i + 1].ff + col[j].ff - val[ {i + 1, j}];
		if (j + 1 < m) ans2 = row[i].ff + col[j + 1].ff - val[ {i, j + 1}];
		if (cur > max(ans1, ans2)) break;
		else if (ans1 >= ans2) i++;
		else j++;
	}
	cout << ans << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


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

def solve():
    n = int(input())

    ans = 999999
    for a in range(1, -(-n // 2)+1):
        t = digits(a) + digits(n-a)
        if(t < ans):
            ans = t

    print(ans)


def digits(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)


if __name__ == "__main__":
    solve()


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

typedef pair<string,int> P;

int check(string str,string at){
    for(int i = 0 ; i < 8 ; i++){
        if(str[i] != at[i] && at[i] != '*') return 0;
    }

    return 1;
}

int main(){
    int n,m,money;
    string str,ss;
    
    while(cin >> n >> m , n+m){
        vector<P> v;
        for(int i = 0 ; i < n ; i++){
            cin >> str >> money;
            v.push_back(P(str,money));
        }
        
        int sum = 0;
        for(int i = 0 ; i < m ; i++){
            cin >> ss;
            for(int j = 0 ; j < n ; j++){
                if(check(ss,v[j].first)){
                    sum += v[j].second;
                }
            }
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <fstream>
#include <set>
#include <tuple>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
int main() {
	int n; std::cin >> n;
	std::vector<int> tall(n); for (auto& t : tall) std::cin >> t;
	std::unordered_map<int, int> add, sub;
	for (auto i = 0; i < n; ++i) {
		add[i + tall[i]]++;
		sub[i - tall[i]]++;
	}
	long long int sum{ 0 };
	for (const auto a : add) {
		sum += (long long int)a.second * sub[a.first];
	}
	std::cout << sum << '\n';
}

Measured memory_bytes: 27056
package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}



Measured memory_bytes: 5912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  auto check = [&](int x, int y) {
    if(s[x][y] == '.') return true;
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    rep(i, 4) {
      int nx = dx[i] + x;
      int ny = dy[i] + y;
      if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '#') return true;
    }
    return false;
  };
  bool ans = true;
  rep(i, h)rep(j, w) {
    if(!check(i, j)) {
      ans = false;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a,b,d,i;
  cin>>a;
  int j[a],k[a],l[a];
  
  for(i=0;i<a;++i){
    cin>>b;
    if(i)j[i]=j[i-1]+b;
    else j[i]=b;}
  
  for(i=0;i<a;++i)cin>>k[i];
  
  for(i=a-1;i>=0;--i){
    if(i==a-1)l[i]=k[i];
    else l[i]=l[i+1]+k[i];}
  d=0;
  for(i=0;i<a;++i){
    int m=j[i]+l[i];
  d=d>m?d:m;}
  cout<<d<<endl;}



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

int main(){
    int N;
    cin >> N;
    vector<char> S(N);
    for (int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    vector<int> E(N,0);
    vector<int> W(N,0);
    for (int i = 0; i < N ; i++){
        if (i != N-1){
            W.at(i+1)=W.at(i);
            if(S.at(i)=='E') E.at(i)++;
            else W.at(i+1)++;
            E.at(i+1)=E.at(i);
        }
        else{
            if(S.at(i)=='E') E.at(i)++;
        }
    }
   
    int ans;
    int mans = N;
    for (int i = 0; i < N; i++){
        ans = W.at(i) + (E.at(N-1) - E.at(i));
        
        if (mans > ans) mans = ans;
    }
    
    cout << mans << endl;
}


Measured memory_bytes: 2944
ans = []
type = [[1]]
que = []
N = int(input())
for i in range(N-1):
    que = type
    type = []
    while len(que) != 0:
        t = que.pop()
        ma = max(t)
        for j in range(1,ma+2):
            type.append(t + [j])
type.sort()
char = " abcdefghijklmnopqrstuvwxyz"
for a in type:
    print("".join(map(lambda x: char[x], a)))


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

int main() {
  int h, a;
  cin >> h >> a;
  int count = 0;
  for (int i = 0; ; i++) {
    h -= a;
    count += 1;
    if (h <= 0) {
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = input()
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    s = n.index("A")

    emax=0
    for i in range(len(n)):
        if n[i] == "Z":
            emax = i

    print(emax - s +1)


resolve()

Measured memory_bytes: 40048
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  string S;

  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    cout << "x";
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int n = ni();
    int[] a = na(n);

    for (int v : a) {
      if (v % 2 == 1) {
        System.out.println("first");
        return;
      }
    }
    System.out.println("second");
    
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 38852
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    x, y = LI()
    d = defaultdict(int)
    d[3] = 100000
    d[2] = 200000
    d[1] = 300000
    print(d[1] * 2 + 400000 if x == y == 1 else d[x] + d[y])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long ans = 0;
        for(int i=0;i<N;i++){
            A[i] = sc.nextLong();
        }
        Arrays.sort(A);

        int point = N-2;
        int count =2;
        for(int i=0;i<N;i++){
            if(i == 0){

            } else if(i == 1){
                ans += A[N-1];
            } else {
                ans += A[point];
                count--;
            }

            if(count == 0){
                count = 2;
                point--;
            }
        }
        System.out.println(ans);


    }

}




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

int main(){
	int a=0, b=0, c=0;
	string A, B, C;
	char X='a';
	cin >> A >> B >> C;
	while(1){
		if(X=='a'){
			if(a==A.size()){
				cout << 'A' << endl;
				break;
			}
			X=A[a];
			a++;

		} else if(X=='b'){
			if(b==B.size()){
				cout << 'B' << endl;
				break;
			}
			X=B[b];
			b++;
		} else if(X=='c'){
			if(c==C.size()){
				cout << 'C' << endl;
				break;
			}
			X=C[c];
			c++;
		}
	}		
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n,f=0;
 cin >> n;
 for(int i=0;i<50000;i++){
   if((int)(i*1.08)==n){
     cout << i;
     f=1;
     break;
   }   
 }
 if(f==0) cout << ":(";
  return 0;
}

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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int N;
  cin >> N;
  vector<pair<int, int>> A;
  rep(i, N) {
    int x;
    cin >> x;
    A.push_back(P(x, i + 1));
  }

  sort(all(A));

  rep(i, N) { cout << A[i].second << (i != N - 1 ? " " : ""); }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b);
    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
 /////////////////////////////////////////////////////
int main(){
	int a[3];
	int ans = 0;
	REP(i,3) SCD(a[i]);
	
	sort(a,a+3);
	int A,B,C;
	A = a[0]; B=a[1]; C = a[2];
	
	while(A + 2 <= C){
		A = A + 2;
		ans++;
	}
	
	while(B + 2 <= C){
		B = B + 2;
		ans++;
	}
	
	a[0] = A; a[1]=B;a[2]=C;
	sort(a,a+3);
	A = a[0]; B=a[1]; C = a[2];
	if (A==C){
	}else if (B==C){
		ans = ans + 2;
	}else if (A==B){
		ans++;
	}
	
	PRINTD(ans);
		
}




Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - ∙ (Bullet)
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef pair<ll,ll> pll;
typedef map<pll,int> mpli;

/* global variables */

mpli ms;

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m > 0, n > 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int zn = 0;
  for (int i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld%lld", &a, &b);

    if (a == 0) {
      if (b == 0) zn++;
      else ms[pll(0, 1)]++;
    }
    else {
      if (b == 0) ms[pll(1, 0)]++;
      else {
	if (a < 0) a = -a, b = -b;
	ll g = gcd<ll>(a, abs(b));
	a /= g, b /= g;
	ms[pll(a, b)]++;
      }
    }
  }

  int p = 1;
  for (mpli::iterator mit = ms.begin(); mit != ms.end(); mit++)
    if (mit->second > 0) {
      int pp = powmod(2, mit->second);

      ll a = mit->first.first, b = mit->first.second;
      ll a0, b0;
      if (a == 0) a0 = 1, b0 = 0;
      else if (b == 0) a0 = 0, b0 = 1;
      else {
	a0 = b, b0 = -a;
	if (a0 < 0) a0 = -a0, b0 = -b0;
      }

      mpli::iterator mit0 = ms.find(pll(a0, b0));
      if (mit0 != ms.end() && mit0->second > 0) {
	pp = (pp + (powmod(2, mit0->second) + MOD - 1) % MOD) % MOD;
	mit0->second = 0;
      }

      p = (ll)p * pp % MOD;
    }

  int sum = (zn + (p + MOD - 1) % MOD) % MOD;
  printf("%d\n", sum);
  return 0;
}


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

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

    for (int i = 0; i <= N/7 ; ++i) {
        if ((N - 7 * i) % 4 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int link[110];
int c[110],d[110];
int a[110],b[110];
int mapp[110][110];
int vis[110];
struct node
{
    int x,y;
}arr[110],brr[110];
bool findd(int x)
{
     for(int j=1;j<=n;j++)
     {
         if(mapp[x][j] && vis[j]==false)
         {
             vis[j]=1;
             if(link[j]==0 || findd(link[j]))
             {
                 link[j]=x;
                 return true;
             }
         }
     }
     return false;
}
int main()
{
    while(cin>>n)
    {
        memset(mapp,0,sizeof(mapp));
        memset(link,0,sizeof(link));
        int x,y;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i]>>b[i];
        }
        for(int i=1;i<=n;i++)
        {
            cin>>c[i]>>d[i];
        }

        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if((a[i]<c[j]) && (b[i]<d[j]))
                {
                    mapp[i][j]=1;
                }
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            memset(vis,0,sizeof(vis));
            if(findd(i)) ans++;
        }
        cout<<ans<<endl
;    }
return 0;
}


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

Measured memory_bytes: 35744
package main

import (
	"fmt"
)

func main() {
	var N string
	var K int
	fmt.Scan(&N, &K)
	d := len(N)
	var dp [2][5][111]int

	dp[0][0][0] = 1
	for i := 0; i < d; i++ {
		for k := 0; k < 4; k++ {
			for x := 0; x < 10; x++ {
				k2 := k
				if x != 0 {
					k2 = k + 1
				}
				dp[1][k2][i+1] += dp[1][k][i]
				if int(N[i]-'0') == x {
					dp[0][k2][i+1] += dp[0][k][i]
				} else if int(N[i]-'0') > x {
					dp[1][k2][i+1] += dp[0][k][i]
				}
			}
		}
	}
	ans := dp[0][K][d] + dp[1][K][d]
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int r, g, b;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    int cnt = 0;
    while(g <= r) {
        g *= 2;
        cnt ++;
    }
    while(b <= g) {
        b *= 2;
        cnt ++;
    }
    cout << (cnt <= k ? "Yes\n": "No\n");
}

int main() {_
    int t = 1;
    //cin >> t;
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

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

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

int main(void) {
	char s[101] = { 0 };
	int len, i, j, sp, x, ans, pre_ans;
	int *eq;

	scanf("%s", &s);
	len = strlen(s);
	eq = (int*)malloc(sizeof(int)*len);
	for (i = 0; i < len; i++) eq[i] = 0;

	ans = len;
	for (i = 0; i < len; i++) {
		if (eq[i] == 0) {
			x = i;
			j = i + 1;
			pre_ans = i;
			while (j < len) {
				if (s[x] == s[j]) {
					sp = j - x - 1;
					x = j;
					eq[j] = 1;
					pre_ans = max(sp, pre_ans);
				}
				else if (j == len - 1) {
					pre_ans = max(pre_ans, len - x - 1);
				}
				j++;
			}
			ans = min(ans, pre_ans);
		}
	}

	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    string s, t;
    cin >> s >> t;

    constexpr int64_t K = 'z' - 'a' + 1;
    vector<vector<int64_t>> a(s.size(), vector<int64_t>(K, -1));
    vector<int64_t> b(K, -1);
    for (auto i : irange(0uL, (s.size())) | reversed) {
        for (auto j : irange(0L, K)) {
            if (b[j] == -1) {
                continue;
            }
            a[i][j] = b[j] - i;
        }
        b[s[i] - 'a'] = i;
    }

    for (auto i : irange(0uL, (s.size())) | reversed) {
        for (auto j : irange(0L, K)) {
            if (a[i][j] == -1 && b[j] != -1) {
                a[i][j] = b[j] - i + s.size();
            }
        }
    }

    int64_t ans = b[t[0] - 'a'];
    if (ans == -1) {
        cout << -1 << endl;
        return 0;
    }
    for (auto i : irange(1uL, t.size())) {
        auto tmp = a[ans % s.size()][t[i] - 'a'];
        if (tmp == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans += tmp;
    }
    ++ans;

    cout << ans << endl;
}

Measured memory_bytes: 24704
#include <iostream>
#include <utility>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

long double dist(long double a,long double b){
    return sqrt(a * a + b * b);
}

double N;
vector<pair<long double, long double>> pair_vec;
long double sum = 0;

int main(){
    cin >> N;
    pair_vec.resize(N);
    for (int i = 0; i < N;i++)
        cin >> pair_vec[i].first >> pair_vec[i].second;

    for (int i = 0; i < N - 1; i++)
        for (int j = i + 1; j < N; j++){
            long double dx = pair_vec[i].first  - pair_vec[j].first;
            long double dy = pair_vec[i].second - pair_vec[j].second;
            sum +=dist(dx,dy);
        }
    
    sum = (2.0 * sum) / N;
    cout << fixed << setprecision(15) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;


int main(void) {
    ll N, M, Q;
    cin >> N >> M >> Q;
    ll i, j;
    ll L, R;
    ll G[501][501]={0};
    ll S[501][501];
    ll p, q;
    for(i=0; i<M; i++) {
        cin >> L >> R;
        L--; R--;
        G[L][R]++;
    }
    S[0][0]=G[0][0];
    for(i=1; i<N; i++) {
        S[i][0]=S[i-1][0]+G[i][0];
    }
    for(i=1; i<N; i++) {
        S[0][i]=S[0][i-1]+G[0][i];
    }
    for(i=1; i<N; i++) {
        for(j=1; j<N; j++) {
            S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]+G[i][j];
        }
    }
    
    for(i=0; i<Q; i++) {
        cin >> p >> q;
        p--; q--;
        cout << S[q][q]-S[p-1][q]-S[q][p-1]+S[p-1][p-1] << endl;
    }
    
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
//#include <string.h>
//#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
/*struct shi
{
    int x;
    int T;
} s[100000];
int cmp(shi a,shi b)
{
    return a.x<b.x;
}
long long cmd(long long a, long long  b)
{
    return a > b;
}*/
int dp[1000000],hh[1000000];
int mox[]= {1,0};
int moy[]= {0,1};
int sx,sy;
int ex,ey;
int n,r;
int falg,step=INF;
/*void dfs(int a, int b,int sum){
    sum+=dp[a][b];
    if(a<=n)
        dfs(a+1,b,sum);
    if(b<=r)
        dfs(a,b+1,sum);
    if(a==n&&b==r&&sum>0&&sum<step)
        step = sum;
}*/
int h[1000000]= {0};
char s[100];
int main()
{
    scanf("%d",&n);
    memset(hh,0x3f,sizeof(hh));
    for(int i=1; i<=n; i++)
    {
        cin >>s;
        memset(dp,0,sizeof(dp));
        //int len = s.length();
        for(int j=strlen(s)-1; j>=0; j--)

            dp[s[j]]++;
           // cout<<s[j];

        for(int j='a'; j<='z'; j++)
            hh[j]=min(hh[j],dp[j]);

    }
    for(int j='a'; j<='z'; j++)
    {
        for(int k=0; k<hh[j]; k++)
            putchar(j);
    }

    return 0;

}


Measured memory_bytes: 8448
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int A,B,C;
	scanf("%d %d %d", &A, &B, &C);

	printf("%d\n",A*B/2);


	return 0;

}


Measured memory_bytes: 256
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e5 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int dp[104][N], w[N], v[N];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1;i <= n; i++){
        cin >> w[i] >> v[i];
    }

    memset(dp,0x3f3f3f3f,sizeof(dp));
    for(int i = 1;i <= n; i++){
        dp[i][0] = 0;
    }
    dp[1][v[1]] = w[1];
    for(int i = 2;i <= n; i++){
        for(int j = v[i];j < N; j++){
            dp[i][j] = min(dp[i][j],dp[i - 1][j - v[i]] + w[i]);
        }
        for(int j = 1;j < N; j++){
            dp[i][j] = min(dp[i][j],dp[i - 1][j]);
        }
    }

    for(int i = N - 1; i >= 1; i--){
        if(dp[n][i] <= m){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 81536
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	int n,m,ans=0;
	cin >> n >> m;
  	int h[n],a[m],b[m],s[n];
  	rep(i,n){
      cin >> h[i];
      s[i] = 0;
    }
  	rep(i,m){
      cin >> a[i] >> b[i];
    }
	rep(i,m){
     	if(h[a[i]-1] < h[b[i]-1]){
         	 s[a[i]-1]--;
        }else if(h[a[i]-1] == h[b[i]-1]){
          	 s[a[i]-1]--; s[b[i]-1]--;
        } else {
        	 s[b[i]-1]--;
        }
    }
  	rep(i,n){
        //cout << s[i] << '\n';
     	if(s[i]==0){
         	ans++ ; 
        }
    }
	cout << ans;   
	return 0;
}

Measured memory_bytes: 5152
# coding: utf-8
# Your code here!

syukuhaku_kei = int(input())
rennzoku = int(input())
tousyo = int(input())
rennpaku  = int(input())

if syukuhaku_kei > rennzoku:
    first_sum = rennzoku*tousyo
    second_sum = (syukuhaku_kei - rennzoku) * rennpaku
    goukei = first_sum + second_sum
    print(str(goukei))
    
else:
    goukei = syukuhaku_kei* tousyo
    print(str(goukei))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int main()
{
	int n;
	int numbers[100];
	int all=0;
	int avg;
	int value1=0, value2=0;
	scanf("%d\n", &n);
	for (int i = 0; i < n-1; i++) {
		scanf("%d ", &numbers[i]);
		all += numbers[i];
	}
	scanf("%d", &numbers[n - 1]);
	all += numbers[n - 1];
	avg = all / n;
	for (int i = 0; i < n; i++) {
		value1 += (numbers[i]-avg)*(numbers[i] - avg);
		value2 += (numbers[i] - avg-1)*(numbers[i] - avg-1);
	}
	if (value1 < value2) printf("%d", value1);
	else printf("%d", value2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long


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

  int a,b; cin >> a >> b;

  auto f = [&](int i){
    if(i%4 == 0) return i;
    if(i%4 == 1) return 1LL;
    if(i%4 == 2) return i+1;
    return 0LL;
  };
  cout << (f(b)^f(a-1)) << endl;

  return 0;
}


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

int main()
{
    long long N,now,d;
    now=1;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>d;
        long long g=__gcd(d,now);
        now=now/g*d;
    }
    cout<<now;
    return 0;
}


Measured memory_bytes: 256
MOD = 998244353
class mint:
    def __init__(self, x):
        if isinstance(x, int):
            self.x = x % MOD 
        elif isinstance(x, mint):
            self.x = x.x
        else:
            self.x = int(x) % MOD 
    def __str__(self):
        return str(self.x)
    __repr__ = __str__
    def __iadd__(self, other):
        self.x += other.x if isinstance(other, mint) else other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __isub__(self, other):
        self.x += MOD-other.x if isinstance(other, mint) else MOD-other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __imul__(self, other):
        self.x *= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __add__(self, other):
        return (
            mint(self.x + other.x) if isinstance(other, mint) else
            mint(self.x + other)
        )
    def __sub__(self, other):
        return (
            mint(self.x - other.x) if isinstance(other, mint) else
            mint(self.x - other)
        )
    def __mul__(self, other):
        return (
            mint(self.x * other.x) if isinstance(other, mint) else
            mint(self.x * other)
        )
    def __floordiv__(self, other):
        return (
            mint(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(self.x * pow(other, MOD - 2, MOD))
        )
    def __pow__(self, other):
        return (
            mint(pow(self.x, other.x, MOD)) if isinstance(other, mint) else
            mint(pow(self.x, other, MOD))
        )
    __radd__ = __add__
    def __rsub__(self, other):
        return (
            mint(other.x - self.x) if isinstance(other, mint) else
            mint(other - self.x)
        )
    __rmul__ = __mul__
    def __rfloordiv__(self, other):
        return (
            mint(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(other * pow(self.x, MOD - 2, MOD))
        )
    def __rpow__(self, other):
        return (
            mint(pow(other.x, self.x, MOD)) if isinstance(other, mint) else
            mint(pow(other, self.x, MOD))
        )


n,s = map(int, input().split())
a = list(map(int, input().split()))
import copy
dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        dp[i+1][j]=dp[i][j]*2
        if j-a[i]>=0:
            dp[i+1][j]+=dp[i][j-a[i]]
        dp[i+1][j]%=MOD
print(dp[n][s])

Measured memory_bytes: 149036
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a, b, c;
    cin >> a >> b >> c;
    lli ans = a;
    rep(i,b+1){
        ans = a*i;
        ans %= b;
        if(ans==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3604
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=int(2e5);
vector<int> lnk[2*N+5];
int n,m;
char fla[N+5];
int tag[2*N+5];
void DFS(int u){
	tag[u]=1;
	for(int i=0;i<lnk[u].size();i++){
		int v=lnk[u][i];
		if(tag[v]==0)
			DFS(v);
		if(tag[v]==1){
			printf("Yes\n");
			exit(0);
		}
	}
	tag[u]=-1;
}
int main(){
	scanf("%d%d%s",&n,&m,fla+1);
	for(int i=0;i<m;i++){
		int u,v;scanf("%d%d",&u,&v);
		if(fla[u]==fla[v]){
			lnk[u].push_back(v+n);
			lnk[v].push_back(u+n);
		}
		else{
			lnk[u+n].push_back(v);
			lnk[v+n].push_back(u);
		}
	}
	for(int i=1;i<=n;i++)
		if(tag[i]==0)
			DFS(i);
	printf("No\n");
	return 0;
}

Measured memory_bytes: 26624
s = input()
k = int(input())
l = 1
ans = 0
c = []

for i in range(len(s)-1):
  if s[i] == s[i+1]:
    l += 1
  else:
    if c == []:
      c.append(l)
    ans += l//2
    l = 1
    
ans += l//2
if c == []:
  c.append(l)
ans *= k

if len(s) == l:
  ans = k*l//2
elif s[0] == s[-1] and l%2 == 1 and c[0]%2 == 1:
  ans += k-1
  
print(ans)

Measured memory_bytes: 3064
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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 Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  vector<ll> tmp(n+1);
  tmp[0]=0;
  rep(i,n) tmp[i+1]=tmp[i]+v[i];
  vector<ll> ans(n-k+1);
  rep(i,n-k+1) ans[i]=tmp[i+k]-tmp[i];
  ll ans2=0;
  rep(i,n-k+1) chmax(ans2,ans[i]);
  cout<<fixed<<setprecision(6)<<(double)(k+(ans2-k)*0.5)<<endl;
}

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

using namespace std;

void Main()
{
    int t, x;
    cin >> t >> x;

    cout << (long double)t / (long double)x;
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define int long long


signed main(){

int mod=1000000007;

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#else
// online submission
#endif

int n;
cin >> n;
long double arr[n+1] ;

for(int i=1;i<=n;i++)
cin >> arr[i] ;

long double  dp[3000] ={0};


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

for(int j=i ; j >=0 ; j--)	{

if(i==0 && j==0){
	dp[j]=1.0;
}

else if(i==0){
dp[j]=0.0;	
}

else if(j==0){
	dp[j]=dp[j]*(1-arr[i]);
}
else 
dp[j]=dp[j-1]*arr[i] + dp[j]*(1-arr[i]) ;

//cout<<dp[j] ;
	
}

}


long double ans=0;
for(int i=n/2+1 ; i <= n ; i++ ){
	ans+=dp[i];
}
cout<<setprecision(10)<<ans;
	return 0;
    
}




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

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

    char c;
    c = tolower(S[K - 1]);
    S[K - 1] = c;
    cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll heap;

int main(){
    cin >> n;
    heap = vll(n+1);
    for(lli i = 1;i <= n;i++) cin >> heap[i];
    for(lli i = 1;i <= n;i++){
        cout << "node " << i << ": ";
        cout << "key = " << heap[i] << ", ";
        if(i/2) cout << "parent key = " << heap[i/2] << ", ";
        if(i*2 <= n) cout << "left key = " << heap[i*2] << ", ";
        if(i*2+1 <= n) cout << "right key = " << heap[i*2+1] << ", ";
        cout << endl;
    }
}

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  rep(i,k){
    if(b<=a){b*=2;continue;}
    if(c<=b){c*=2;continue;}
  }
  string ans="No";
  if(a<b and b<c) ans="Yes";
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3624