akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int X, Y, result=0;

  cin >> X >> Y;

  if(X==1){
    result += 300000;
  }else if(X==2){
    result += 200000;
  }else if(X==3){
      result += 100000;
  }

  if(Y==1){
    result += 300000;
  }else if(Y==2){
    result += 200000;
  }else if(Y==3){
      result += 100000;
  }
    if(X==1 && Y==1){
        result +=400000;
    }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  ll N,K;
  cin >> N >> K;
  if(0 == N%K){
    cout << 0<< endl;
  }else{
    ll ans = K - (N % K);
    cout << ((ans < N)?ans:N) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    string s_a = "", s_b = "";
    rep (i, 0, a) s_a += to_string(b);
    rep (i, 0, b) s_b += to_string(a);

    if (s_a > s_b) cout << s_b << endl;
    else cout << s_a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String[] args) throws Exception{
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    System.out.println(check(S));
    sc.close();
  }
  static String check(String s) {
    char[] cList = s.toCharArray();
    //aaパターン
    for (int i = 0; i < cList.length - 1 ; i++) {
      if (cList[i] == (cList[i+1])) {
        return (i+1) + " " + (i+2);
      }
    }
    //abaパターン
    for (int i = 0; i < cList.length - 2 ; i++) {
      if (cList[i] == (cList[i+2])) {
        return (i+1) + " " + (i+3);
      }
    }
    // no match
    return (-1) + " " + (-1);
  }
}

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

const int maxn = 2e5 + 5;
int n;
int a[maxn];
int val[maxn];

map<int, int> mp;

bool check(int val){
    mp.clear();
    for(int i = 2;i <= n;i++){
        if(a[i] > a[i - 1])
            continue;
        else if(a[i] <= a[i - 1]){
            auto it = mp.upper_bound(a[i]);
            mp.erase(it, mp.end());
            int t = a[i];
            while(t > 0 and mp[t] == val - 1){
                mp.erase(t);
                t--;
            }
            if(t == 0)
                return 0;
            mp[t]++;
        }
    }
    return true;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    bool flag = true;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        if(i > 1 and a[i] <= a[i - 1])
            flag = false;
    } 
    if(flag){
        cout << 1 << endl;
    }else{
        int l = 2, r = n;
        while(l < r){
            int mid = (l + r) / 2;
            if(check(mid))
                r = mid;
            else
                l = mid + 1;
        }
        cout << l << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const int Maxn=1e6+5;
int gcd(int a,int b)
{
	if(a==0)
	return 0;
	else return (b==0)?a:gcd(b,a%b);
}
int main()
{
   int k,ans=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int p=1;p<=k;p++){
                ans+=gcd(gcd(i,j),p);
            }
        }
    }
    cout<<ans;
    return 0;
} 

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

int main() {
    int n;
    int a1[100];
    int a2[100];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a1[i];
    }
    for(int i=0;i<n;i++){
        cin >> a2[i];
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<i+1;j++){
            sum += a1[j];
        }
        for(int j=i;j<n;j++){
            sum += a2[j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

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

    int b = 0, w = 0;
    REP( i, N ){
        if( s[i] == '.' ) w++;
    }

    int ans = INF;
    REP( i, N ){
        chmin( ans, b + w );

        if( s[i] == '.' ) w--;
        else b++;

        chmin( ans, b + w );
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define present(c, x) (c.find(x) != c.end())

using namespace std;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii
int main() {
    // ll n, k;
    // cin >> n >> k;
    // vi a;
    // for (int i = 0; i < n; i++) {
    //     cin >> a[i];
    // }
    ll x;
    cin >> x;
    ll one = x / 500;
    ll two = (x % 500) / 5;
    cout << one * 1000 + two * 5 << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    void run() {
        int MAX = 30001;
        boolean isPrime[] = new boolean[MAX];
        List<Integer> primes = new ArrayList<Integer>();
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i < MAX; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i + i; j < MAX; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        Scanner sc = new Scanner(System.in);
        while (true) {
            int T = sc.nextInt();
            if (T == 0)
                break;
            int ans = 0;
            for (int i = 0; i < primes.size(); i++) {
                int a = primes.get(i);
                if (a >= T)
                    break;
                for (int j = i; j < primes.size(); j++) {
                    int b = primes.get(j);
                    int c = T - a - b;
                    if (c < 0 || c < b)
                        break;
                    if (a + b > c && c > Math.abs(b - a))
                        if (isPrime[c]) {
                            ans++;
                        }
                }
            }
            System.out.println(ans);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 12000
#ABC088-D-Greid Repainting
from collections import deque

h,w = map(int,input().split())
grid = ["" for _ in range(h)]

#'#'の個数-> cnt
cnt = 0
for i in range(h):
    grid[i] = input()
    cnt += grid[i].count('#')
        
dist = [[float('inf') for _ in range(w)] for _ in range(h)]

dist[0][0] = 0

P = deque([])
P.append((0,0))

while P:
    p = P.popleft()
    x,y = p[0],p[1]
    for dx,dy in ((1,0),(0,1),(-1,0),(0,-1)):
        nx,ny = x + dx, y+dy
        if 0 <= nx and 0 <= ny and nx <= h-1 and ny <= w-1 and grid[nx][ny] == '.' and dist[nx][ny] == float('inf'):
            dist[nx][ny] = dist[x][y] + 1
            P.append((nx,ny))
            
if dist[h-1][w-1] == float('inf'):
    print(-1)
    
else:
    print(h*w - dist[h-1][w-1] - cnt -1)



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

int main()
{
    string s,t,r;
    cin >> s >> t >> r;
    cout << 'A' << t[0] << 'C' << endl;
}

Measured memory_bytes: 256
n, m=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

K=50*100
ikd=Array.new(K+1){0}
ikd[0]=1
a.each do |e|
  K.downto 0 do |j|
    if ikd[j]!=0
      raise unless e+j<=K
      ikd[e+j]+=ikd[j]
    end
  end
end

ans=0
ikd.each_with_index do |e, i|
  ans+=e if i%2==m
end
puts ans


Measured memory_bytes: 1788
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
	int g[50];
	int x[50];
int n,m;
int a[50],b[50];
int i;
int c;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
	
	scanf("%d%d",&a[i],&b[i]);
	
	
	
	
	
	
	
}
for(i=0;i<50;i++){
	
	
	g[i]=0;
	x[i]=0;
	
	
	
	
	
}
for(i=0;i<n;i++){
	for(c=0;c<m;c++){
		if(i+1==a[c]){
			
			g[i]++;
			
			
			
		}
		if(i+1==b[c]){
			
			x[i]++;
			
			
			
			
		}
		
		
		
		
		
		
	}
	
	
	
	
	
	
}
for(i=0;i<n;i++){
	
	printf("%d\n",g[i]+x[i]);
	
	
	
	
	
	
}

	return 0;
}

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

int main() {
  // ここにプログラムを追記
  
  int a, b;
  cin >> a >> b;
  
  //平均値
  double c = (a + b) % 2;
  
  if(c == 0){
    
    cout << (a + b) / 2 << endl;
  }
  
  else{
    
    cout << (a + b) / 2 + 1 << endl;
  }

  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
const int maxn=6666;
std::string a,b,c; 
bool ab[maxn<<1],ac[maxn<<1],bc[maxn<<1];
int ans=maxn<<2;
inline bool cmp(char c1,char c2) {return c1==c2||c1=='?'||c2=='?';}
signed main()
{
	std::cin>>a>>b>>c; int lena=a.length(),lenb=b.length(),lenc=c.length();
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenb;++j) if(!cmp(a[i],b[j])) ab[i-j+maxn]=1;
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenc;++j) if(!cmp(a[i],c[j])) ac[i-j+maxn]=1;
	for(rgi i=0;i<lenb;++i) for(rgi j=0;j<lenc;++j) if(!cmp(b[i],c[j])) bc[i-j+maxn]=1;
	for(rgi i=-4001;i<=4001;++i) for(rgi j=-4001;j<=4001;++j)
		if(!ab[i+maxn]&&!ac[j+maxn]&&!bc[j-i+maxn])
			ans=std::min(ans,std::max(lena,std::max(i+lenb,j+lenc))-std::min(0,std::min(i,j)));
	std::cout<<ans;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


int n, p, cnt;
bool flag;

int main() {
	flag = false;
	cnt = 0;
	cin >> n;
	lp(n) {
		cin >> p;
		if (p == i + 1) {
			if (!flag)
				cnt++;
			flag = !flag;
		}
		else flag = false;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ITP1_5_C
{
	class Program
	{
		static void Main(string[] args)
		{
			List<Tuple<int, int>> ts = new List<Tuple<int, int>>();

			while(true) {
				string[] vs = Console.ReadLine().Split(' ');

				int h = int.Parse(vs[0]);
				int w = int.Parse(vs[1]);

				if(h == 0 && w == 0) {
					break;
				}

				ts.Add(Tuple.Create(h, w));
			}

			foreach(Tuple<int, int> t in ts) {
				for(int i = 0; i < t.Item1; i++) {
					for(int j = 0; j < t.Item2; j++) {
						if(i % 2 == 0) {
							Console.Write(j % 2 == 0 ? "#" : ".");
						}
						else {
							Console.Write(j % 2 == 0 ? "." : "#");
						}
					}
					Console.WriteLine();
				}

				Console.WriteLine();
			}
		}
	}
}



Measured memory_bytes: 18076
def partition(A,p,r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x[1]:
            i+=1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1
    
def quickSort(A,p,r):
    if p<r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)
        
n = int(input())
data = []
for i in range(n):
    m,num = map(str,input().split())
    data.append([m, int(num)])
data1 = data[:]

quickSort(data,0,n-1)

for i in range(n-1):
    if data[i][1] == data[i+1][1]:
        if data1.index(data[i]) > data1.index(data[i+1]):
            print("Not stable")
            break
else:
    print("Stable")

for i in data:
    print(' '.join(str(d) for d in i))



Measured memory_bytes: 18580
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  string S;
  cin>>S;
  ll N=S.size();
  string A,B;
  A=S.substr(0,(N-1)/2);
  B=S.substr((N+3)/2-1,N);
  
  for(ll i=0;i<N/2;i++){
    if(S[i]!=S[N-i-1]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(ll i=0;i<A.size()/2;i++){
    if(A[i]!=A[A.size()-i-1]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(ll i=0;i<B.size()/2;i++){
    if(B[i]!=B[B.size()-i-1]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main2(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(A*x//B-A*(x//B))

if N>=B-1:
    Z=B-1
else:
    Z=N
print((main2(Z)))

#print(C)


Measured memory_bytes: 72672
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        printf("a < b\n");
    }
    else if(a>b)
    {
        printf("a > b\n");
        
    }
    else
    {
        printf("a == b\n");
    }
}


Measured memory_bytes: 2624
#include <cstdio>

using namespace std;

long long dp[2000001];

int main() {
    int n, m = 1000000007, i;
    long long sum = 0;
    
    scanf("%d", &n);
    
    for (i = n; i < n * 2; i++) dp[i] = 1;
    dp[n - 1] = n;
    
    for (i = 1; i < n; i++) sum += dp[n + i];
    sum %= m;
    
    for (i = n - 2; i >= 0; i--) {
        dp[i] = (long long)(n - 1) * (n - 1) % m;
        dp[i] += sum;
        dp[i] += dp[i + 1];
        dp[i] %= m;
        
        sum -= dp[i + n + 1];
        if (sum < 0) sum += m;
        sum += dp[i + 2];
        if (sum > m) sum -= m;
    }
    
    printf("%lld\n", dp[0]);
    
    return 0;
}


Measured memory_bytes: 15744
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

R, C, K = getNM()
point = [[0] * C for i in range(R)]
for i in range(K):
    r, c, v = getNM()
    point[r - 1][c - 1] = v

# dp[j][n] j列目にn個まで取った時の最大値
# 蟻本で出た前と後のdpを取り替える作業をしないと盛大にTLEる
prev = [[0] * 4 for _ in range(C + 1)]

for i in range(R):
    next = [[0] * 4 for _ in range(C + 1)]
    for j in range(C):
        # ①取った時
        # n = 2, n = 1, n = 0と逆順にやらないとバグる
        # ②より扱うjの数が小さくなるので先に処理する
        for n in range(2, -1, -1):
            prev[j][n + 1] = max(prev[j][n + 1], prev[j][n] + point[i][j])

        # ②取らない時
        for n in range(4):
            prev[j + 1][n] = max(prev[j + 1][n], prev[j][n])

        # ③下段に降りた時
        next[j][0] = max(prev[j])

    prev = next

print(max(prev[C - 1]))

Measured memory_bytes: 231216
#include "bits/stdc++.h"
using namespace std;
template<typename T, typename S> void amax(T &a, S b){ if(a < b) a = b; }
template<typename T, typename S> void amin(T &a, S b){ if(a > b) a = b; }
#define rep(a,b,c) for(int a = b; a < c; a++)
#define per(a,b,c) for(int a = b; a > c; a--)
#define rit(it,v) for(auto &it:v)
#define mset(a, b) memset(a, b, sizeof(a))
#define mt make_tuple
#define pb push_back
using ii = pair<int,int>;
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vll = vector<ll>;
const ll mod = 1000000007;
ll powm(ll a, ll b){ll ans=1;a %= mod;for(;b;b>>=1){if(b&1)ans=ans*a%mod;a = a*a%mod;}return ans;}
const int maxn = 101010;
int main(){
	int a, b, c; cin >> a >> b >> c;
	if(c >= a && c <= b) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2020-03-17.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<ll> A, B;

int main() {
    cin >> N;
    A.assign(N, 0);
    for (int i = 0; i < N; ++i) cin >> A[i];
    B.assign(N, 0);

    for (int i = 0; i < N; ++i) B[0] += i % 2 == 0 ? A[i] : -A[i];
    for (int i = 1; i < N; ++i) B[i] = 2 * A[i-1] - B[i-1];

    for (int i = 0; i < N - 1; ++i) {
        cout << B[i] << " ";
    }
    cout << B[N-1] << endl;
    return 0;
}

Measured memory_bytes: 2944
/*---------------Go Code GO---------------*/

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

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a
#define     MOD             1000000007


bitset<64> num[300005];
int arr[300005][64];
int main()
{
    long long i,j,k,l,m,n,o,q,r,tst;
    unsigned long long ans=0, p;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>k;
        num[i]=bitset<64>(k);
    }
    for(i=n-1; i>=0; i--)
    {
        for(j=63; j>=0; j--)
        {
            if(num[i][j]) arr[i][j]=1;
            arr[i][j]+=arr[i+1][j];
        }
    }
    //cout<<"ekhane";
    ans=0;
    for(i=0; i<n; i++)
    {
        //cout<<num[i].to_string()<<endl;
        for(j=63; j>=0; j--)
        {
            if(num[i][j])
            {
                p=n-i-arr[i][j];
                ans+=(p*((1LL<<j)%MOD));
                ans=ans%MOD;
                //cout<<j<<'+'<<p<<' '<<num[i][j]<<endl;
            }
            else
            {
                p=arr[i][j];
                ans+=(p*((1LL<<j)%MOD));
                ans=ans%MOD;
                //cout<<j<<'-'<<p<<endl;
            }
        }
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 77568
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    sort(ALL(a));

    vector<ll> b(m), c(m);
    rep(i, m)cin >> b[i] >> c[i];

    vector<ll> ord(m);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](ll x, ll y){
        return c[x] > c[y];
    });

    ll back = 0;
    rep(i, m){
        if(back >= n)break;
        ll p = ord[i];

        rep(j, b[p]){
            if(a[back] >= c[p])back = n;
            if(back >= n)break;

            a[back] = c[p];

            back++;
        }
    }

    ll ans = 0;
    rep(i, n)ans+=a[i];
    cout << ans << endl;
}

Measured memory_bytes: 6408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int S = scan.nextInt();
		int	h = S/3600;
		int m = (S % 3600)/60;
		int s = S-(h*3600 + m*60);
		System.out.println(h + ":" + m + ":" + s);	
	}
}

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

int main (void) {
    int N, w_c = -1, r_c = -1, count = 0, j = 0;
    scanf("%d\n", &N);
    char t;
    int w[N], r[N];
    for (int i = 0; i < N; i++) {
        scanf("%c", &t);
        if (t == 'R') {
            r_c++;
            r[r_c] = i;
        } else if (t == 'W') {
            w_c++;
            w[w_c] = i;
        }
    }

    while (r[r_c] > w[j] && r_c >= 0 && j <= w_c) {
        count++;
        r_c--;
        j++;
    }

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

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<pii> ab(n);
	rep(i, n) cin >>ab[i].second >>ab[i].first;
	
	sort(all(ab));
	int now =0;
	rep(i, n){
		now += ab[i].second;
		if(now > ab[i].first){
			puts("No"); return 0;
		}
		
	}
	puts("Yes");
	return 0;
}


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

typedef long long ll;
 
const int INF= 1001001001;
const ll LINF= 1e18;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n; i++) cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l = -1;
    ll r = LINF;
    while(r-l > 1){
        ll m = (r+l) >> 1;
        ll cnt = 0;
        for(int i = 0; i < n; i++){
            if(a[i]*f[i]>m){
                cnt += (a[i]*f[i]-m)/f[i];
                if((a[i]*f[i]-m)%f[i]) cnt++;
            }
        }
        if(cnt > k) l = m;
        else r = m;
    }
    cout << r << endl;
}


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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	int n, k; cin>>n>>k;
	int ans = 0;
	vector< int > v(n);
	for(int &i : v){
		cin>>i;
		ans += min(2 * abs(k - i), 2 * i);
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}



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

using namespace std;

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

	int count = 0;
	int total = 0;
	while (true) {
		total += x;
		count++;
		if (total == 360) {
			cout << count << endl;
			return 0;
		}
		else if (total > 360) {
			total -= 360;
		}
	}
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
const ll mod=1000000007LL;

#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}

const int limit=1000;
ll C[1010][1010];

void init(){
	rep(i,limit+1){
		rep(j,i+1){
			if(j==0 or j==i)
				C[i][j]=1LL;
			else
				C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
		}
	}
}

ll dp[1010][1010];
ll num[1010][1010];

ll inv[1010];
ll fact[1010];


int main(void){
	init();

	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;

	inv[1]=1LL;
	rep(i,2,limit+1) inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	
	fact[0]=1LL;
	rep(i,1,limit+1) fact[i]=1LL*i*fact[i-1]%mod;

	
	num[0][0]=1LL;
	rep(i,1,limit+1)rep(j,1,i+1){
		if(i%j!=0) continue;
		int unit=i/j;
		num[i][j]=1LL*C[i][unit]*num[i-unit][j-1]%mod*inv[j]%mod;
	}

	dp[a][n]=1LL;
	rep(i,a,b+1){
		rep(k,n+1){
			dp[i+1][k]+=dp[i][k];
			dp[i+1][k]%=mod;
		}

		rep(j,c,d+1){
			rep(k,i*j,n+1){	
				ll add=1LL*dp[i][k]%mod*C[k][i*j]%mod*num[i*j][j]%mod;
				dp[i+1][k-i*j]+=add;
				dp[i+1][k-i*j]%=mod;
			}
		}
	}

	//rep(i,a,b+2)rep(j,n+1) error(i,j,dp[i][j]);
	// 280
	cout << dp[b+1][0] << endl;
	return 0;
}

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

int main() {
	int A,B;cin>>A>>B;
	
	if ((A + B) % 2)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		cout<<(A+B)/2<<endl;
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int t[110000], x[110000], y[110000];
    t[0] = 0, x[0] = 0, y[0] = 0;
    for(int i=1; i<=n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    bool isok = true;
    for(int i=0; i<n; i++){
        int dt = t[i+1] - t[i];
        int d = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(!(dt >= d && abs(dt-d)%2 ==0)){
            isok = false;
            break;
        }
    }

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

Measured memory_bytes: 1408
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int main(void){


  int n;

  cin >> n;
  int k = 0;

  if (n >= 100){
    k++;
    n -= 100;
  }

  if (n >= 10){
    k++;
    n -= 10;
  }

  if (n >= 1){
    k++;
  }

  cout << k << endl;

return 0;



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    string s;
    cin >> s;
    
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    int flag = 0;
    for(int i = 2; i < s.length() - 1; i++) {
        if(s[i] == 'C')
            flag++;
    }
    if (flag != 1) {
        cout << "WA" << endl;
        return 0;
    }

    rep(i,s.length()) {
        if (i == 0 || s[i] == 'C')
            continue;
        if (s[i] < 'a' || s[i] > 'z') {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  //string s;cin>>s;
  int n;cin>>n;n++;
  string s=to_string(n);
  int a=s[0]-'0';
  cout<<a-1+9*(s.length()-1)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
   int N;
    
    int a_max = 0;
    int a_min = INT_MAX;
   
    cin >> N;
    
    for ( int i = 0; i < N; i++ ) {
        int temp;
        cin >> temp;
        
        
        if ( a_max < temp ) {
            a_max = temp;
        }
        if ( a_min > temp ) {
            a_min = temp;
        }
    }
    
    
    cout << a_max - a_min << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;
    ll ans = 0;
    bool remain = false;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if (remain) {
            if (a == 0) {
                remain = false;
            } else {
                a += 1;
                ans += a / 2;
                if (a % 2 == 0) {
                    remain = false;
                }
            }
        } else {
            ans += a / 2;
            if (a % 2 == 1) {
                remain = true;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#Miccさんのコードを参考にさせていただきました
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = v[1::2] #偶数番号
o = v[0::2] #奇数番号
ans = 0

a = Counter(e) #Counterオブジェクトを作成(dictのサブクラスでキーに要素、値に出現回数をもつ)
b = Counter(o)

c = a.most_common(2) #出現回数が2番目に多い数までのCounterオブジェクト作成
d = b.most_common(2)

if c[0][0] != d[0][0]: #出現回数が１番多いものが違う時
    ans = n -c[0][1] -d[0][1]
else:                  #出現回数が１番多いものが同じ時
    if len(c) == 1:
        if len(d) == 1:
            ans = n//2
        else:
            ans = n -d[0][1]
    elif len(d) == 1 and len(c) != 1:
        ans = n -c[0][1]
    elif c[0][1] > d[0][1]:
        ans = n -c[0][1] -d[1][1]
    else:
        if c[0][1]==d[0][1]:
            ans = min(n-c[0][1]-d[1][1],n-c[1][1]-d[0][1])
        else:
            ans = n -c[1][1] -d[0][1]
    
print(ans)

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

template<typename T> inline void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> inline void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }


#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

#define A 0
#define C 1
#define G 2
#define T 3

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

    vector<vector<vector<vector<ll>>>> dp;
    ndarray(dp,N+1,4,4,4);
    //dp[i][x][y][z]i桁目まで決定、右端3つが左からx,y,zと並びNGパターンを含まない要求文字列の場合の数
    dp[0][3][3][3]=1;
    rep(i,4)rep(j,4)rep(k,4)dp[3][i][j][k]=1;
    dp[3][A][G][C]=0;
    dp[3][G][A][C]=0;
    dp[3][A][C][G]=0;
    for(int l=4;l<=N;l++){
        rep(i,4)rep(j,4)rep(k,4)dp[l][i][j][k]=0;
        
        rep(x,4) rep(y,4) rep(z,4) rep(w,4){
            if(        y==A && z==G && w==C)continue;
            if(        y==G && z==A && w==C)continue;
            if(        y==A && z==C && w==G)continue;
            if(x==A         && z==G && w==C)continue;
            if(x==A && y==G         && w==C)continue;
            dp[l][y][z][w]+=dp[l-1][x][y][z];
            dp[l][y][z][w]%=mod;
        }
        
    }
    ll ans=0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans+=dp[N][i][j][k];
                ans%=mod;
            }
        }
    }

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

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int e[]=new int[b];
	int count=0;
	int ans=0;
	for(int i=0;i<b;i++) {
		e[i]=scan.nextInt();
	}
	for(int i=0;i<a;i++) {
		count=0;
		for(int j=0;j<b;j++){
			int f=scan.nextInt()*e[j];
			count+=f;
		}
		if(count+c>0) {
			ans++;
		}
	}
	System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const dd eps = 1e-5;
const ll mod = 1e9+7;

struct node{
  string name;
  int num;
}a[N];
map<string,int> g;
bool cmp(node p1,node p2){
  if(p1.num == p2.num) return p1.name < p2.name;
  return p1.num > p2.num;
}
int n,cnt;
string now;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++){
    cin>>now;
    if(!g[now]) g[now] = ++cnt;
    a[g[now]].name = now;
    a[g[now]].num++;
  }
  sort(a+1,a+1+cnt,cmp);
  int st = 1;
  while(true){
    if(a[1].num != a[st].num) break;
    cout<<a[st++].name<<endl;
  }
  return 0;
}


Measured memory_bytes: 28288
from collections import deque
s = deque(list(input()))
q = int(input())
flg = True
for _ in range(q):
    try:
        t,f,c = input().split()
        if flg:
            if f == "1":
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f == "1":
                s.append(c)
            else:
                s.appendleft(c)
    except ValueError:
        if flg:
            flg = False
        else:
            flg = True
if flg:
    print(''.join(s))
else:
    s = list(reversed(s))
    print(''.join(s))

Measured memory_bytes: 103908
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=998244353;
// 1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



int main(){
  auto end=[](){cout<<-1<<endl; exit(0);};
  ll N;
  cin>>N;
  vector<ll> A(N),B(N);
  cin>>A>>B;
  auto sum=[&](ll idx)->ll{return B[(idx+N-1)%N]+B[(idx+1)%N];};
  auto good=[&](ll idx)->bool{return B[idx]>A[idx] && B[idx]>sum(idx);};
  queue<ll> Q;
  for(int i=0;i<N;i++){
    if(B[i]<A[i]){end();}
    if(B[i]>A[i] && B[i]>sum(i)){Q.push(i);}
  }
  ll ans=0;
  while(!Q.empty()){
    ll idx=Q.front(); Q.pop();
    ll s=sum(idx);
    ll k=(B[idx]-A[idx])/s;
    ans+=k;
    B[idx]-=s*k;
    if(good((idx+1)%N)){Q.push((idx+1)%N);}
    if(good((idx+N-1)%N)){Q.push((idx+N-1)%N);}
  }
  if(A==B){cout<<ans<<endl;}
  else{cout<<-1<<endl;}
  

  return 0;
}


Measured memory_bytes: 4224
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();
    int c = sc.nextInt();
    
    if (a == b) {
      System.out.println(c);
    } else if (b == c) {
      System.out.println(a);
    } else if (c == a) {
      System.out.println(b);
    }
  }
}

Measured memory_bytes: 21844
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int maxn=100100;

int n;

int p[maxn];

int a[maxn];
int b[maxn];

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

  cin>>n;

  for(int i=0;i<n;i++)
    cin>>p[i];

  for(int i=0;i<n;i++)
    a[i]=b[n-1-i]=i*20002+1;

  for(int i=0;i<n;i++)
    {
      p[i]--;
      a[p[i]]+=i;
      b[p[i]]+=i;
    }
  
  for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
  cout<<endl;
  for(int i=0;i<n;i++)
    cout<<b[i]<<" ";
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
void listup(vector<int> da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size()-1)
			cout << da[i] << endl;
		else
			cout << da[i] << ' ';
	}
}

int main() {
	int n,sum=0;
	cin >> n;
	vector<long long> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
		sum += da[i];
	}
	int x = (sum + 1) / 2;
	vector<long long> dp(sum + 1,0);
	dp[0] = 1;
	for (int i = 0;i < n;i++) {
		//listup(dp);
		for (int j = sum - da[i];j > -1;j--) {
			int m= (dp[j] + dp[j + da[i]] * 2) % 998244353;
			dp[j + da[i]] = m;
		}
		for (int j = da[i]-1;j>-1;j--)
			dp[j] = (dp[j] * 2) % 998244353;
	}
	long long la = 0;
	for (int i = x;i < sum + 1;i++) {
		la = (la + dp[i]) % 998244353;
	}
	//la += dp[0];
	//listup(dp);
	//cout << la << endl;
	vector<long long> gg(sum + 1,0);
	gg[0] = 1;
	if (sum % 2 == 0) {
		for (int i = 0;i < n;i++) {
			//listup(dp);
			for (int j = sum - da[i];j > -1;j--) {
				int m = (gg[j] + gg[j + da[i]]) % 998244353;
				gg[j + da[i]] = m;
			}
		}
		la -= gg[sum / 2];
		//cout << gg[sum / 2] << endl;
	}
	long long ans = 1;
	for (int i = 0;i < n;i++) {
		ans = (long long)(ans * 3) % 998244353;
	}
	//cout << ans << ' ' << la << endl;
	ans = (long long) (ans - la * 3) % 998244353;
	if (ans < 0)
		ans += 998244353;
	cout << ans << endl;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numS = sc.nextInt();
		int numT = sc.nextInt();
		long s[] = new long[numS];
		for(int i = 0; i < numS; i ++) {
			s[i] = sc.nextLong();
		}
		long t[] = new long[numT];
		for(int i = 0; i < numT; i ++) {
			t[i] = sc.nextLong();
		}
		long dp[][] = new long[numS + 1][numT + 1];
		long dpSum[][] = new long[numS + 1][numT + 1];
		for(int i = 0; i <= numS; i ++) {
			dp[i][0] = 0;
			dpSum[i][0] = 1;
		}
		for(int i = 0; i <= numT; i ++) {
			dp[0][i] = 0;
			dpSum[0][i] = 1;
		}
		dp[0][0] = 1;

		for(int i = 1; i <= numS; i ++) {
			for(int j = 1; j <= numT; j ++) {
				dpSum[i][j] = mod(dpSum[i - 1][j] + dpSum[i][j - 1] - dpSum[i - 1][j - 1]);
				if(s[i - 1] != t[j - 1]) { dp[i][j] = 0; continue; }
				dp[i][j] = dpSum[i - 1][j - 1];
				dpSum[i][j] = mod(dpSum[i][j] + dp[i][j]);
			}
		}

		long ans = 0;
		for(int i = 0; i <= numS; i ++) {
			for(int j = 0; j <= numT; j ++) {
				ans = mod(ans + dp[i][j]);
			}
		}

		System.out.println(mod(ans));
	}

	static long MOD = (long)Math.pow(10, 9) + 7;
	public static long mod(long i) {
		return i % MOD + ((i % MOD) < 0 ? MOD : 0);
	}
	
	static long powerMod(long x, long y) {
		if (y == 0) {
			return 1;
		} else if (y == 1) {
			return x;
		} else if (y % 2 == 0) {
			long tmp = powerMod(x, y / 2);
			return mod(tmp * tmp);
		} else {
			long tmp = powerMod(x, y / 2);
			return mod(mod(tmp * tmp) * x);
		}
	}
	
	static long invMod(long x) {
		return powerMod(x, MOD - 2);
	}
	
	static int MAX_FACT = 200_100;
	static long factMod[] = new long[MAX_FACT];
	static void prepareFact() {
		factMod[0] = 1;
		for(int i = 1; i < MAX_FACT; i ++) {
			factMod[i] = mod(factMod[i - 1] * i);
		}
	}
	
	static long combiMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0 || r == n) { return 1; }
		return mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));
	}
}

Measured memory_bytes: 130584
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    int a;cin>>a;
    string s;cin>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
    
}


Measured memory_bytes: 256
from scipy.sparse import*
e=enumerate
_,*s=open(0)
r=s+['#'*20]
*g,=eval('[0]*500,'*500)
for i,t in e(s):
  for j,u in e(t):
    k=i*20+j
    g[k][k+1]=u>'#'<t[j+1]
    g[k][k+20]=u>'#'<r[i+1][j]  
a=csgraph.johnson(csr_matrix(g),0)
print(int(a[a<999].max()))

Measured memory_bytes: 19344
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;

    cout << (char)(S1[0] - 'a' + 'A') << (char)(S2[0] - 'a' + 'A') << (char)(S3[0] - 'a' + 'A') << endl;

    return 0;

}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	string a,b;
	cin>>a>>b;
	int c,d;
	cin>>c>>d;
	string res;
	cin>>res;
	if(res==a)
		cout<<c-1<<" "<<d<<endl;
	else if(res==b)
		cout<<c<<" "<<d-1<<endl;
	else
		cout<<c<<" "<<d<<endl;


}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  int n;
  cin>> n ;
  int k=2*n ;
  vector<int> A(k) ;
  rep(i,k) cin>> A[i] ;
  sort(A.begin(),A.end()) ;
  int ans=0 ;
  rep(i,n){
    ans+=A[i*2] ;
  }
  cout <<ans<<endl ; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N];
ll s,k;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi(),s+=a[i];
    ll tmp=1ll*n*(n+1)/2;
    if(s%tmp!=0) return puts("NO"),0;
    k=s/tmp;
    for(int i=1;i<n;i++) if((k-a[i+1]+a[i])%n!=0||k-a[i+1]+a[i]<0) return puts("NO"),0;
    if((k-a[1]+a[n])%n!=0||k-a[1]+a[n]<0) puts("NO");
    else puts("YES");
    return 0;
}


Measured memory_bytes: 640